aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common-logging/checkstyle-suppressions.xml30
-rw-r--r--common-logging/pom.xml18
-rw-r--r--common-logging/src/main/java/org/onap/policy/common/logging/OnapLoggingContext.java (renamed from common-logging/src/main/java/org/onap/policy/common/logging/ONAPLoggingContext.java)92
-rw-r--r--common-logging/src/main/java/org/onap/policy/common/logging/OnapLoggingUtils.java (renamed from common-logging/src/main/java/org/onap/policy/common/logging/ONAPLoggingUtils.java)26
-rw-r--r--common-logging/src/main/java/org/onap/policy/common/logging/eelf/DroolsPdpMdcInfo.java (renamed from common-logging/src/main/java/org/onap/policy/common/logging/eelf/DroolsPDPMDCInfo.java)21
-rw-r--r--common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventData.java36
-rw-r--r--common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfo.java20
-rw-r--r--common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfoHandler.java4
-rw-r--r--common-logging/src/main/java/org/onap/policy/common/logging/eelf/MdcInfo.java (renamed from common-logging/src/main/java/org/onap/policy/common/logging/eelf/MDCInfo.java)12
-rw-r--r--common-logging/src/main/java/org/onap/policy/common/logging/eelf/OnapConfigProperties.java (renamed from common-logging/src/main/java/org/onap/policy/common/logging/eelf/Configuration.java)41
-rw-r--r--common-logging/src/main/java/org/onap/policy/common/logging/eelf/PolicyLogger.java421
-rw-r--r--common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/DisplayUtils.java41
-rw-r--r--common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/EelfLogger.java114
-rw-r--r--common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/FlexLogger.java70
-rw-r--r--common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/Logger.java12
-rw-r--r--common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/Logger4J.java92
-rw-r--r--common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/PropertyUtil.java28
-rw-r--r--common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/SystemOutLogger.java149
-rw-r--r--common-logging/src/main/java/org/onap/policy/common/logging/nsa/LoggingContextFactory.java12
-rw-r--r--common-logging/src/test/java/org/onap/policy/common/logging/eelf/DroolsPdpMdcInfoTest.java (renamed from common-logging/src/test/java/org/onap/policy/common/logging/eelf/DroolsPDPMDCInfoTest.java)19
-rw-r--r--common-logging/src/test/java/org/onap/policy/common/logging/eelf/EventDataTest.java22
-rw-r--r--common-logging/src/test/java/org/onap/policy/common/logging/eelf/EventTrackInfoTest.java28
-rw-r--r--common-logging/src/test/java/org/onap/policy/common/logging/eelf/PolicyLoggerTest.java121
-rw-r--r--common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/EelfLoggerTest.java71
-rw-r--r--common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/FlexLoggerTest.java32
-rw-r--r--common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/Logger4JTest.java96
-rw-r--r--common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/SystemOutLoggerTest.java25
-rw-r--r--common-logging/src/test/java/org/onap/policy/common/logging/util/TestUtils.java77
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpoint.java5
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointManager.java37
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxy.java63
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicSink.java14
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicSource.java34
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicFactories.java43
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSink.java11
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkFactory.java9
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSource.java10
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceFactory.java32
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedDmaapTopicSourceFactory.java8
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedUebTopicSourceFactory.java8
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicFactories.java43
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSink.java5
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSource.java5
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicFactories.java43
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSink.java10
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSource.java10
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumer.java43
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisher.java10
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSource.java9
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/client/TopicSinkClient.java4
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/features/NetLoggerFeatureApi.java7
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/features/NetLoggerFeatureProviders.java41
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClient.java9
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientConfigException.java44
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactory.java17
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactoryInstance.java37
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/IndexedHttpClientFactory.java14
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServer.java28
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServerFactoryInstance.java38
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyJerseyServer.java3
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/properties/PolicyEndPointProperties.java164
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/DmaapPropertyUtils.java15
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/NetLoggerUtil.java5
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/ParameterUtils.java3
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicFactoryTestBase.java33
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkTest.java4
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceFactoryTest.java13
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceTest.java4
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSinkTest.java4
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSourceFactoryTest.java13
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSourceTest.java4
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumerTest.java4
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/client/TopicSinkClientTest.java12
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java69
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpExceptionsTest.java33
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java96
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEndpoints.java14
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/CommonTestData.java15
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/RestServerParametersTest.java8
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/TopicParameterGroupTest.java6
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/NetLoggerUtilTest.java3
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/ParameterUtilsTest.java11
-rw-r--r--utils/src/main/java/org/onap/policy/common/utils/network/NetworkUtil.java2
-rw-r--r--utils/src/test/java/org/onap/policy/common/utils/network/NetworkUtilTest.java2
84 files changed, 1555 insertions, 1406 deletions
diff --git a/common-logging/checkstyle-suppressions.xml b/common-logging/checkstyle-suppressions.xml
deleted file mode 100644
index 0d169509..00000000
--- a/common-logging/checkstyle-suppressions.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0"?>
-<!--
- ============LICENSE_START=======================================================
- Copyright (C) 2018 AT&T Technologies. 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=========================================================
--->
-
-<!DOCTYPE suppressions PUBLIC
- "-//Puppy Crawl//DTD Suppressions 1.0//EN"
- "http://www.puppycrawl.com/dtds/suppressions_1_0.dtd">
-
-<suppressions>
- <suppress checks="AbbreviationAsWordInName"
- files="ONAPLoggingUtils.java|ONAPLoggingContext.java|DroolsPDPMDCInfo.java|Logger.java|EventData.java|EventTrackInfo.java|MDCInfo.java|PolicyLogger.java|SystemOutLoggerTest.java|Logger4JTest.java|EelfLoggerTest.java|PolicyLoggerTest.java|DroolsPDPMDCInfoTest.java|EventTrackInfoTest.java|HttpClientTest.java"
- lines="1-9999"/>
-</suppressions>
diff --git a/common-logging/pom.xml b/common-logging/pom.xml
index 8e34d66f..851dabb8 100644
--- a/common-logging/pom.xml
+++ b/common-logging/pom.xml
@@ -2,14 +2,14 @@
============LICENSE_START=======================================================
ONAP Policy Engine - Common Modules
================================================================================
- 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.
@@ -33,6 +33,11 @@
<dependencies>
<dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<scope>provided</scope>
@@ -51,6 +56,10 @@
<artifactId>eelf-core</artifactId>
<version>1.0.1-oss</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ </dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
@@ -81,7 +90,6 @@
<includeTestResources>true</includeTestResources>
<excludes>
</excludes>
- <suppressionsLocation>${project.basedir}/checkstyle-suppressions.xml</suppressionsLocation>
<consoleOutput>true</consoleOutput>
<failsOnViolation>true</failsOnViolation>
<violationSeverity>warning</violationSeverity>
@@ -110,7 +118,7 @@
</execution>
</executions>
<dependencies>
- <!-- We need to include the dependency of the project so that its include
+ <!-- We need to include the dependency of the project so that its include
in classpath when running plugin -->
<dependency>
<groupId>org.onap.policy.common</groupId>
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/ONAPLoggingContext.java b/common-logging/src/main/java/org/onap/policy/common/logging/OnapLoggingContext.java
index 92bc6236..0373abfe 100644
--- a/common-logging/src/main/java/org/onap/policy/common/logging/ONAPLoggingContext.java
+++ b/common-logging/src/main/java/org/onap/policy/common/logging/OnapLoggingContext.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP-Logging
* ================================================================================
- * 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.
@@ -40,7 +40,7 @@ import org.slf4j.MDC;
* creates). Example: log4j.appender.auditAppender.layout=org.apache.log4j.EnhancedPatternLayout
* log4j.appender.auditAppender.layout.ConversionPattern=%d|%X{requestId}|%X{serviceInstanceId}|...|%m%n
* where "requestId" and "serviceInstanceId" are entries in the MDC hashmap.
- *
+ *
* <p>The notable functionality the SharedLoggingContext adds over MDC is that it maintains its own
* copy of the MDC data items in a hashmap (not in ThreadLocal storage), which allows more control
* of the data. The ONAPLoggingContext constructor that takes another ONAPLoggingContext object as a
@@ -49,7 +49,7 @@ import org.slf4j.MDC;
* requests, and for each request, create a new logging context with that base context as a
* parameter; this will create a new logging context with those initial values and none of the
* request-specific values from the previous request such as a request ID.
- *
+ *
* <p>The setter methods in this class set corresponding items in the SharedLoggingContext/MDC
* hashmaps. These items correspond to the fields defined in the "ONAP platform application logging
* guidelines" document. In addition, there is a pair of convenience functions, transactionStarted()
@@ -57,7 +57,7 @@ import org.slf4j.MDC;
* calculate the duration of the transaction and record that value in the "timer" item.
*
*/
-public class ONAPLoggingContext {
+public class OnapLoggingContext {
private static final String REQUEST_ID = "requestId";
private static final String SERVICE_INSTANCE_ID = "serviceInstanceId";
@@ -98,7 +98,7 @@ public class ONAPLoggingContext {
/**
* Create a new ONAPLoggingContext with no base context.
*/
- public ONAPLoggingContext() {
+ public OnapLoggingContext() {
context = (SharedLoggingContext) loggingContextBuilder.forSharing().build();
}
@@ -109,10 +109,10 @@ public class ONAPLoggingContext {
* unchanging and common to all the threads. That constant data can be populated in a base
* context, and then each request handler creates new context passing that base context to
* populate the common data in the new one.
- *
+ *
* @param baseContext onap logging context
*/
- public ONAPLoggingContext(ONAPLoggingContext baseContext) {
+ public OnapLoggingContext(OnapLoggingContext baseContext) {
context = (SharedLoggingContext) loggingContextBuilder.forSharing().build();
// a logging context could be passed into a thread (e.g. one that is servicing a queue)
// that already had a logging context established, so the MDC hashmap could contain
@@ -174,16 +174,16 @@ public class ONAPLoggingContext {
*
* @param id request identifier
*/
- public void setRequestID(String id) {
+ public void setRequestId(String id) {
context.put(REQUEST_ID, id);
}
/**
* Get the value for the data item with key "requestId".
- *
+ *
* @return current value, or empty string if not set
*/
- public String getRequestID() {
+ public String getRequestId() {
return context.get(REQUEST_ID, EMPTY_STRING);
}
@@ -192,16 +192,16 @@ public class ONAPLoggingContext {
*
* @param id service identifier
*/
- public void setServiceInstanceID(String id) {
+ public void setServiceInstanceId(String id) {
context.put(SERVICE_INSTANCE_ID, id);
}
/**
* Get the value for the data item with key "serviceInstanceId".
- *
+ *
* @return current value, or empty string if not set
*/
- public String getServiceInstanceID() {
+ public String getServiceInstanceId() {
return context.get(SERVICE_INSTANCE_ID, EMPTY_STRING);
}
@@ -211,16 +211,16 @@ public class ONAPLoggingContext {
*
* @param id thread identifier
*/
- public void setThreadID(String id) {
+ public void setThreadId(String id) {
context.put(THREAD_ID, id);
}
/**
* Get the value for the data item with key "threadId".
- *
+ *
* @return current value, or empty string if not set
*/
- public String getThreadID() {
+ public String getThreadId() {
return context.get(THREAD_ID, EMPTY_STRING);
}
@@ -235,7 +235,7 @@ public class ONAPLoggingContext {
/**
* Get the value for the data item with key "serverName".
- *
+ *
* @return current value, or empty string if not set
*/
public String getServerName() {
@@ -253,7 +253,7 @@ public class ONAPLoggingContext {
/**
* Get the value for the data item with key "serviceName".
- *
+ *
* @return current value, or empty string if not set
*/
public String getServiceName() {
@@ -271,7 +271,7 @@ public class ONAPLoggingContext {
/**
* Get the value for the data item with key "partnerName".
- *
+ *
* @return current value, or empty string if not set
*/
public String getPartnerName() {
@@ -289,7 +289,7 @@ public class ONAPLoggingContext {
/**
* Get the value for the data item with key "statusCode".
- *
+ *
* @return current value, or empty string if not set
*/
public String getStatusCode() {
@@ -307,7 +307,7 @@ public class ONAPLoggingContext {
/**
* Get the value for the data item with key "targetEntity".
- *
+ *
* @return current value, or empty string if not set
*/
public String getTargetEntity() {
@@ -325,7 +325,7 @@ public class ONAPLoggingContext {
/**
* Get the value for the data item with key "targetServiceName".
- *
+ *
* @return current value, or empty string if not set
*/
public String getTargetServiceName() {
@@ -337,16 +337,16 @@ public class ONAPLoggingContext {
*
* @param uuid instance uuid
*/
- public void setInstanceUUID(String uuid) {
+ public void setInstanceUuid(String uuid) {
context.put(INSTANCE_UUID, uuid);
}
/**
* Get the value for the data item with key "instanceUuid".
- *
+ *
* @return current value, or empty string if not set
*/
- public String getInstanceUUID() {
+ public String getInstanceUuid() {
return context.get(INSTANCE_UUID, EMPTY_STRING);
}
@@ -361,7 +361,7 @@ public class ONAPLoggingContext {
/**
* Get the value for the data item with key "severity".
- *
+ *
* @return current value, or empty string if not set
*/
public String getSeverity() {
@@ -371,18 +371,18 @@ public class ONAPLoggingContext {
/**
* Set the value for the data item with key "serverIp".
*
- * @param serverIP server ip address
+ * @param serverIp server ip address
*/
- public void setServerIPAddress(String serverIP) {
- context.put(SERVER_IP_ADDRESS, serverIP);
+ public void setServerIpAddress(String serverIp) {
+ context.put(SERVER_IP_ADDRESS, serverIp);
}
/**
* Get the value for the data item with key "serverIp".
- *
+ *
* @return current value, or empty string if not set
*/
- public String getServerIPAddress() {
+ public String getServerIpAddress() {
return context.get(SERVER_IP_ADDRESS, EMPTY_STRING);
}
@@ -397,7 +397,7 @@ public class ONAPLoggingContext {
/**
* Get the value for the data item with key "server".
- *
+ *
* @return current value, or empty string if not set
*/
public String getServer() {
@@ -407,18 +407,18 @@ public class ONAPLoggingContext {
/**
* Set the value for the data item with key "clientIp".
*
- * @param clientIP client ip address
+ * @param clientIp client ip address
*/
- public void setClientIPAddress(String clientIP) {
- context.put(CLIENT_IP_ADDRESS, clientIP);
+ public void setClientIpAddress(String clientIp) {
+ context.put(CLIENT_IP_ADDRESS, clientIp);
}
/**
* Get the value for the data item with key "clientIp".
- *
+ *
* @return current value, or empty string if not set
*/
- public String getClientIPAddress() {
+ public String getClientIpAddress() {
return context.get(CLIENT_IP_ADDRESS, EMPTY_STRING);
}
@@ -437,7 +437,7 @@ public class ONAPLoggingContext {
/**
* Get the value for the data item with key "classname".
- *
+ *
* @return current value, or empty string if not set
*/
public String getClassname() {
@@ -456,7 +456,7 @@ public class ONAPLoggingContext {
/**
* Get the value for the data item with key "TransactionBeginTimestamp".
- *
+ *
* @return current value, or 0 if not set
*/
public long getTransactionBeginTimestamp() {
@@ -475,7 +475,7 @@ public class ONAPLoggingContext {
/**
* Get the value for the data item with key "TransactionEndTimestamp".
- *
+ *
* @return current value, or 0 if not set
*/
public long getTransactionEndTimestamp() {
@@ -498,7 +498,7 @@ public class ONAPLoggingContext {
/**
* Get the value for the data item with key "TransactionElapsedTime".
- *
+ *
* @return current value, or 0 if not set
*/
public long getTransactionElapsedTime() {
@@ -517,7 +517,7 @@ public class ONAPLoggingContext {
/**
* Get the value for the data item with key "MetricBeginTimestamp".
- *
+ *
* @return current value, or 0 if not set
*/
public long getMetricBeginTimestamp() {
@@ -536,7 +536,7 @@ public class ONAPLoggingContext {
/**
* Get the value for the data item with key "MetricEndTimestamp".
- *
+ *
* @return current value, or 0 if not set
*/
public long getMetricEndTimestamp() {
@@ -559,7 +559,7 @@ public class ONAPLoggingContext {
/**
* Get the value for the data item with key "MetricElapsedTime".
- *
+ *
* @return current value, or 0 if not set
*/
public long getMetricElapsedTime() {
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/ONAPLoggingUtils.java b/common-logging/src/main/java/org/onap/policy/common/logging/OnapLoggingUtils.java
index 0983ed6f..dddd3c4d 100644
--- a/common-logging/src/main/java/org/onap/policy/common/logging/ONAPLoggingUtils.java
+++ b/common-logging/src/main/java/org/onap/policy/common/logging/OnapLoggingUtils.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP-Logging
* ================================================================================
- * 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,38 +22,38 @@ package org.onap.policy.common.logging;
import javax.servlet.http.HttpServletRequest;
-public class ONAPLoggingUtils {
+public class OnapLoggingUtils {
- private ONAPLoggingUtils() {}
+ private OnapLoggingUtils() {}
/**
* Get the ONAPLoggingContext for a request.
- *
+ *
* @param request the request
* @param baseContext the context to supply to the ONAPLoggingContext
* @return the ONAPLoggingContext
*/
- public static ONAPLoggingContext getLoggingContextForRequest(HttpServletRequest request,
- ONAPLoggingContext baseContext) {
- ONAPLoggingContext requestContext = new ONAPLoggingContext(baseContext);
+ public static OnapLoggingContext getLoggingContextForRequest(HttpServletRequest request,
+ OnapLoggingContext baseContext) {
+ OnapLoggingContext requestContext = new OnapLoggingContext(baseContext);
if (request.getLocalAddr() != null) { // may be null in junit tests
- requestContext.setServerIPAddress(request.getLocalAddr());
+ requestContext.setServerIpAddress(request.getLocalAddr());
}
// get client IP address as leftmost address in X-Forwarded-For header if present,
// otherwise from remote address in the request
String forwarded = request.getHeader("X-Forwarded-For");
if (forwarded != null && forwarded.trim().length() > 0) {
forwarded = forwarded.trim().split(",")[0];
- requestContext.setClientIPAddress(forwarded);
+ requestContext.setClientIpAddress(forwarded);
} else if (request.getRemoteAddr() != null) { // may be null in junit tests
- requestContext.setClientIPAddress(request.getRemoteAddr());
+ requestContext.setClientIpAddress(request.getRemoteAddr());
}
// RequestID
// This needs to be renamed to ONAP when the other components in ONAP
// rename to this.
String requestId = request.getHeader("X-ECOMP-RequestID");
if (requestId != null && requestId.trim().length() > 0) {
- requestContext.setRequestID(requestId);
+ requestContext.setRequestId(requestId);
}
return requestContext;
}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/DroolsPDPMDCInfo.java b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/DroolsPdpMdcInfo.java
index f5ab4c79..6086a642 100644
--- a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/DroolsPDPMDCInfo.java
+++ b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/DroolsPdpMdcInfo.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP-Logging
* ================================================================================
- * 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.
@@ -20,10 +20,11 @@
package org.onap.policy.common.logging.eelf;
+import com.att.eelf.configuration.Configuration;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-public class DroolsPDPMDCInfo implements MDCInfo {
+public class DroolsPdpMdcInfo implements MdcInfo {
private static ConcurrentHashMap<String, String> mdcMap = new ConcurrentHashMap<>();
@@ -34,19 +35,19 @@ public class DroolsPDPMDCInfo implements MDCInfo {
mdcMap.put(Configuration.MDC_SERVICE_INSTANCE_ID, "Policy.droolsPdp.event");
mdcMap.put(Configuration.MDC_INSTANCE_UUID, "");
mdcMap.put(Configuration.MDC_ALERT_SEVERITY, "");
- mdcMap.put(Configuration.PARTNER_NAME, "N/A");
- mdcMap.put(Configuration.STATUS_CODE, "N/A");
- mdcMap.put(Configuration.RESPONSE_CODE, "N/A");
- mdcMap.put(Configuration.RESPONSE_DESCRIPTION, "N/A");
+ mdcMap.put(OnapConfigProperties.PARTNER_NAME, "N/A");
+ mdcMap.put(OnapConfigProperties.STATUS_CODE, "N/A");
+ mdcMap.put(OnapConfigProperties.RESPONSE_CODE, "N/A");
+ mdcMap.put(OnapConfigProperties.RESPONSE_DESCRIPTION, "N/A");
}
/**
* Get the MMDC Info.
- *
+ *
* @return the instance of ConcurrentHashMap.
*/
@Override
- public ConcurrentMap<String, String> getMDCInfo() {
+ public ConcurrentMap<String, String> getMdcInfo() {
return mdcMap;
}
}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventData.java b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventData.java
index a8d90ad7..23be38ba 100644
--- a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventData.java
+++ b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventData.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP-Logging
* ================================================================================
- * 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.
@@ -21,10 +21,14 @@
package org.onap.policy.common.logging.eelf;
import java.time.Instant;
+import lombok.Getter;
+import lombok.Setter;
/**
* EventData can be used for logging a rule event.
*/
+@Getter
+@Setter
public class EventData {
private String requestId = null;
@@ -40,7 +44,7 @@ public class EventData {
/**
* Create an instance.
- *
+ *
* @param requestId the request ID
* @param startTime the start time
* @param endTime the end time
@@ -51,30 +55,6 @@ public class EventData {
this.endTime = endTime;
}
- public String getRequestID() {
- return requestId;
- }
-
- public void setRequestID(String requestId) {
- this.requestId = requestId;
- }
-
- public Instant getStartTime() {
- return startTime;
- }
-
- public void setStartTime(Instant startTime) {
- this.startTime = startTime;
- }
-
- public Instant getEndTime() {
- return endTime;
- }
-
- public void setEndTime(Instant endTime) {
- this.endTime = endTime;
- }
-
@Override
public String toString() {
return requestId + " Starting Time : " + this.startTime + " Ending Time : " + this.endTime;
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfo.java b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfo.java
index 46401e9e..71476c6a 100644
--- a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfo.java
+++ b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfo.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP-Logging
* ================================================================================
- * 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.
@@ -45,23 +45,23 @@ public class EventTrackInfo {
/**
* Returns an instance of EventData associated to this requestID.
- *
- * @param requestID request id
+ *
+ * @param requestId request id
* @return EventData
*/
- public EventData getEventDataByRequestID(String requestID) {
- return eventInfo.get(requestID);
+ public EventData getEventDataByRequestId(String requestId) {
+ return eventInfo.get(requestId);
}
/**
* Stores an EventData object in a ConcurrentHashMap using its requestID as key.
- *
+ *
* @param event event data
*/
public void storeEventData(EventData event) {
if (event != null) {
- String id = event.getRequestID();
+ String id = event.getRequestId();
if (id == null || id.isEmpty()) {
return;
}
@@ -74,7 +74,7 @@ public class EventTrackInfo {
/**
* Removes an EventData object from a ConcurrentHashMap using the eventId as key.
- *
+ *
* @param eventId event id
*/
public void remove(String eventId) {
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfoHandler.java b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfoHandler.java
index 5f97c365..4b5c57a8 100644
--- a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfoHandler.java
+++ b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfoHandler.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP-Logging
* ================================================================================
- * 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.
@@ -80,7 +80,7 @@ public class EventTrackInfoHandler extends TimerTask {
}
expiredEvents.add(entry.getKey());
- PolicyLogger.info(className + " add expired event request ID: " + event.getRequestID());
+ PolicyLogger.info(className + " add expired event request ID: " + event.getRequestId());
}
}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/MDCInfo.java b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/MdcInfo.java
index f7832271..59b8e8c3 100644
--- a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/MDCInfo.java
+++ b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/MdcInfo.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP-Logging
* ================================================================================
- * 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.
@@ -26,12 +26,12 @@ import java.util.concurrent.ConcurrentMap;
* Interface needs to be implemented by DroolsPDPMDCInfo.
*/
@FunctionalInterface
-public interface MDCInfo {
+public interface MdcInfo {
/**
* Returns MDC info.
- *
+ *
* @return MDC info
*/
- ConcurrentMap<String, String> getMDCInfo();
+ ConcurrentMap<String, String> getMdcInfo();
}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/Configuration.java b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/OnapConfigProperties.java
index 0752b188..8d2031db 100644
--- a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/Configuration.java
+++ b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/OnapConfigProperties.java
@@ -7,9 +7,9 @@
* 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.
@@ -21,62 +21,67 @@
package org.onap.policy.common.logging.eelf;
-public interface Configuration extends com.att.eelf.configuration.Configuration {
+public class OnapConfigProperties {
/**
* The Date-time of the start of a transaction.
*/
- String BEGIN_TIME_STAMP = "BeginTimestamp";
+ public static final String BEGIN_TIME_STAMP = "BeginTimestamp";
/**
* The Date-time of the end of transaction.
*/
- String END_TIME_STAMP = "EndTimestamp";
+ public static final String END_TIME_STAMP = "EndTimestamp";
/**
* Externally advertised API invoked by clients of this component.
*/
- String SERVICE_NAME = "ServiceName";
+ public static final String SERVICE_NAME = "ServiceName";
/**
* Client or user invoking the API.
*/
- String PARTNER_NAME = "PartnerName";
+ public static final String PARTNER_NAME = "PartnerName";
- String TARGET_ENTITY = "TargetEntity";
+ public static final String TARGET_ENTITY = "TargetEntity";
- String TARGET_SERVICE_NAME = "TargetServiceName";
+ public static final String TARGET_SERVICE_NAME = "TargetServiceName";
/**
* High level success or failure (COMPLETE or ERROR).
*/
- String STATUS_CODE = "StatusCode";
+ public static final String STATUS_CODE = "StatusCode";
/**
* Application specific response code.
*/
- String RESPONSE_CODE = "ResponseCode";
+ public static final String RESPONSE_CODE = "ResponseCode";
/**
* Human readable description of the application specific response code.
*/
- String RESPONSE_DESCRIPTION = "ResponseDescription";
+ public static final String RESPONSE_DESCRIPTION = "ResponseDescription";
/**
* Externally advertised API invoked by clients of this component.
*/
- String ELAPSED_TIME = "ElapsedTime";
+ public static final String ELAPSED_TIME = "ElapsedTime";
/**
* High level failure (ERROR).
*/
- String ERROR_CATEGORY = "ErrorCategory";
+ public static final String ERROR_CATEGORY = "ErrorCategory";
- String ERROR_CODE = "ErrorCode";
+ public static final String ERROR_CODE = "ErrorCode";
- String ERROR_DESCRIPTION = "ErrorDescription";
+ public static final String ERROR_DESCRIPTION = "ErrorDescription";
- String CLASS_NAME = "ClassName";
+ public static final String CLASS_NAME = "ClassName";
- String SERVER_NAME = "ServerName";
+ public static final String SERVER_NAME = "ServerName";
+
+
+ private OnapConfigProperties() {
+ // do nothing
+ }
}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/PolicyLogger.java b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/PolicyLogger.java
index 87c4c571..cf0cfb3e 100644
--- a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/PolicyLogger.java
+++ b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/PolicyLogger.java
@@ -28,24 +28,24 @@ import static com.att.eelf.configuration.Configuration.MDC_SERVER_FQDN;
import static com.att.eelf.configuration.Configuration.MDC_SERVER_IP_ADDRESS;
import static com.att.eelf.configuration.Configuration.MDC_SERVICE_INSTANCE_ID;
import static com.att.eelf.configuration.Configuration.MDC_SERVICE_NAME;
-import static org.onap.policy.common.logging.eelf.Configuration.BEGIN_TIME_STAMP;
-import static org.onap.policy.common.logging.eelf.Configuration.ELAPSED_TIME;
-import static org.onap.policy.common.logging.eelf.Configuration.END_TIME_STAMP;
-import static org.onap.policy.common.logging.eelf.Configuration.ERROR_CATEGORY;
-import static org.onap.policy.common.logging.eelf.Configuration.ERROR_CODE;
-import static org.onap.policy.common.logging.eelf.Configuration.ERROR_DESCRIPTION;
-import static org.onap.policy.common.logging.eelf.Configuration.PARTNER_NAME;
-import static org.onap.policy.common.logging.eelf.Configuration.RESPONSE_CODE;
-import static org.onap.policy.common.logging.eelf.Configuration.RESPONSE_DESCRIPTION;
-import static org.onap.policy.common.logging.eelf.Configuration.SERVER_NAME;
-import static org.onap.policy.common.logging.eelf.Configuration.STATUS_CODE;
-import static org.onap.policy.common.logging.eelf.Configuration.TARGET_ENTITY;
-import static org.onap.policy.common.logging.eelf.Configuration.TARGET_SERVICE_NAME;
+import static org.onap.policy.common.logging.eelf.OnapConfigProperties.BEGIN_TIME_STAMP;
+import static org.onap.policy.common.logging.eelf.OnapConfigProperties.ELAPSED_TIME;
+import static org.onap.policy.common.logging.eelf.OnapConfigProperties.END_TIME_STAMP;
+import static org.onap.policy.common.logging.eelf.OnapConfigProperties.ERROR_CATEGORY;
+import static org.onap.policy.common.logging.eelf.OnapConfigProperties.ERROR_CODE;
+import static org.onap.policy.common.logging.eelf.OnapConfigProperties.ERROR_DESCRIPTION;
+import static org.onap.policy.common.logging.eelf.OnapConfigProperties.PARTNER_NAME;
+import static org.onap.policy.common.logging.eelf.OnapConfigProperties.RESPONSE_CODE;
+import static org.onap.policy.common.logging.eelf.OnapConfigProperties.RESPONSE_DESCRIPTION;
+import static org.onap.policy.common.logging.eelf.OnapConfigProperties.SERVER_NAME;
+import static org.onap.policy.common.logging.eelf.OnapConfigProperties.STATUS_CODE;
+import static org.onap.policy.common.logging.eelf.OnapConfigProperties.TARGET_ENTITY;
+import static org.onap.policy.common.logging.eelf.OnapConfigProperties.TARGET_SERVICE_NAME;
+import static org.onap.policy.common.logging.flexlogger.DisplayUtils.displayErrorMessage;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFLogger.Level;
import com.att.eelf.configuration.EELFManager;
-
import java.io.PrintWriter;
import java.io.StringWriter;
import java.net.InetAddress;
@@ -60,7 +60,8 @@ import java.util.Timer;
import java.util.TimerTask;
import java.util.UUID;
import java.util.concurrent.ConcurrentMap;
-
+import java.util.function.Consumer;
+import org.apache.commons.lang3.StringUtils;
import org.onap.policy.common.logging.flexlogger.LoggerType;
import org.slf4j.MDC;
@@ -246,7 +247,7 @@ public class PolicyLogger {
* @param transId the transaction ID
* @return String
*/
- public static String postMDCInfoForEvent(String transId) {
+ public static String postMdcInfoForEvent(String transId) {
MDC.clear();
String transactionId = transId;
@@ -258,7 +259,7 @@ public class PolicyLogger {
if ("DROOLS".equalsIgnoreCase(component)) {
MDC.put(TARGET_ENTITY, "POLICY");
MDC.put(TARGET_SERVICE_NAME, "drools evaluate rule");
- return postMDCInfoForEvent(transactionId, new DroolsPDPMDCInfo());
+ return postMdcInfoForEvent(transactionId, new DroolsPdpMdcInfo());
} else {
// For Xacml
MDC.put(TARGET_ENTITY, "POLICY");
@@ -269,38 +270,11 @@ public class PolicyLogger {
MDC.put(MDC_KEY_REQUEST_ID, transactionId);
MDC.put(MDC_SERVICE_NAME, "Policy.xacmlPdp");
MDC.put(MDC_SERVICE_INSTANCE_ID, "Policy.xacmlPdp.event");
- try {
- MDC.put(MDC_SERVER_FQDN, hostName);
- MDC.put(MDC_SERVER_IP_ADDRESS, hostAddress);
- } catch (Exception e) {
- errorLogger.error(MessageCodes.EXCEPTION_ERROR, e, POLICY_LOGGER);
- }
-
- MDC.put(MDC_INSTANCE_UUID, "");
- MDC.put(MDC_ALERT_SEVERITY, "");
-
- SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
-
- Instant startTime = Instant.now();
- Instant endTime = Instant.now();
-
- String formatedTime = sdf.format(Date.from(startTime));
- MDC.put(BEGIN_TIME_STAMP, formatedTime);
-
- // set default values for these required fields below, they can be overridden
- formatedTime = sdf.format(Date.from(endTime));
- MDC.put(END_TIME_STAMP, formatedTime);
- MDC.put(ELAPSED_TIME, Long.toString(Duration.between(startTime, endTime).toMillis()));
-
- MDC.put(PARTNER_NAME, "N/A");
-
- MDC.put(STATUS_CODE, COMPLETE_STATUS);
- MDC.put(RESPONSE_CODE, "N/A");
- MDC.put(RESPONSE_DESCRIPTION, "N/A");
+ setMdcHostInfo();
+ seTimeStamps();
return transactionId;
-
}
/**
@@ -310,12 +284,12 @@ public class PolicyLogger {
* @param mdcInfo the MDC info
* @return String
*/
- private static String postMDCInfoForEvent(String transId, MDCInfo mdcInfo) {
+ private static String postMdcInfoForEvent(String transId, MdcInfo mdcInfo) {
MDC.put(MDC_KEY_REQUEST_ID, transId);
- if (mdcInfo != null && mdcInfo.getMDCInfo() != null && !mdcInfo.getMDCInfo().isEmpty()) {
+ if (mdcInfo != null && mdcInfo.getMdcInfo() != null && !mdcInfo.getMdcInfo().isEmpty()) {
- ConcurrentMap<String, String> mdcMap = mdcInfo.getMDCInfo();
+ ConcurrentMap<String, String> mdcMap = mdcInfo.getMdcInfo();
Iterator<String> keyIterator = mdcMap.keySet().iterator();
String key;
@@ -325,24 +299,12 @@ public class PolicyLogger {
}
}
- try {
- MDC.put(MDC_SERVER_FQDN, hostName);
- MDC.put(MDC_SERVER_IP_ADDRESS, hostAddress);
- } catch (Exception e) {
- errorLogger.error(MessageCodes.EXCEPTION_ERROR, e, POLICY_LOGGER);
- }
+ setMdcHostInfo();
+
Instant startTime = Instant.now();
Instant endTime = Instant.now();
- SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
-
- String formatedTime = sdf.format(Date.from(startTime));
- MDC.put(BEGIN_TIME_STAMP, formatedTime);
-
- // set default values for these required fields below, they can be overridden
- formatedTime = sdf.format(Date.from(endTime));
- MDC.put(END_TIME_STAMP, formatedTime);
- MDC.put(ELAPSED_TIME, Long.toString(Duration.between(startTime, endTime).toMillis()));
+ seTimeStamps(startTime, endTime);
return transId;
}
@@ -352,8 +314,17 @@ public class PolicyLogger {
*
* @param eventObject event object
*/
- public static void postMDCInfoForEvent(Object eventObject) {
- postMDCInfoForEvent("" + eventObject);
+ public static void postMdcInfoForEvent(Object eventObject) {
+ postMdcInfoForEvent("" + eventObject);
+ }
+
+ private static void setMdcHostInfo() {
+ try {
+ MDC.put(MDC_SERVER_FQDN, hostName);
+ MDC.put(MDC_SERVER_IP_ADDRESS, hostAddress);
+ } catch (Exception e) {
+ errorLogger.error(MessageCodes.EXCEPTION_ERROR, e, POLICY_LOGGER);
+ }
}
/**
@@ -364,18 +335,10 @@ public class PolicyLogger {
MDC.put(MDC_INSTANCE_UUID, "");
MDC.put(MDC_ALERT_SEVERITY, "");
- SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
-
Instant startTime = Instant.now();
Instant endTime = Instant.now();
- String formatedTime = sdf.format(Date.from(startTime));
- MDC.put(BEGIN_TIME_STAMP, formatedTime);
-
- // set default values for these required fields below, they can be overridden
- formatedTime = sdf.format(Date.from(endTime));
- MDC.put(END_TIME_STAMP, formatedTime);
- MDC.put(ELAPSED_TIME, Long.toString(Duration.between(startTime, endTime).toMillis()));
+ seTimeStamps(startTime, endTime);
MDC.put(PARTNER_NAME, "N/A");
@@ -385,6 +348,18 @@ public class PolicyLogger {
}
+ private static void seTimeStamps(Instant startTime, Instant endTime) {
+ SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
+
+ String formatedTime = sdf.format(Date.from(startTime));
+ MDC.put(BEGIN_TIME_STAMP, formatedTime);
+
+ // set default values for these required fields below, they can be overridden
+ formatedTime = sdf.format(Date.from(endTime));
+ MDC.put(END_TIME_STAMP, formatedTime);
+ MDC.put(ELAPSED_TIME, Long.toString(Duration.between(startTime, endTime).toMillis()));
+ }
+
/**
* Sets transaction Id to MDC.
*
@@ -411,7 +386,7 @@ public class PolicyLogger {
* @param transId the transaction ID
* @return String
*/
- public static String postMDCInfoForTriggeredRule(String transId) {
+ public static String postMdcInfoForTriggeredRule(String transId) {
String transactionId = transId;
@@ -424,12 +399,7 @@ public class PolicyLogger {
MDC.put(MDC_KEY_REQUEST_ID, transactionId);
MDC.put(MDC_SERVICE_NAME, "Policy.droolsPdp");
MDC.put(MDC_SERVICE_INSTANCE_ID, "");
- try {
- MDC.put(MDC_SERVER_FQDN, hostName);
- MDC.put(MDC_SERVER_IP_ADDRESS, hostAddress);
- } catch (Exception e) {
- errorLogger.error(MessageCodes.EXCEPTION_ERROR, e, POLICY_LOGGER);
- }
+ setMdcHostInfo();
MDC.put(MDC_INSTANCE_UUID, "");
MDC.put(MDC_ALERT_SEVERITY, "");
MDC.put(STATUS_CODE, COMPLETE_STATUS);
@@ -443,9 +413,9 @@ public class PolicyLogger {
*
* @param obj object
*/
- public static void postMDCUUIDForTriggeredRule(Object obj) {
+ public static void postMdcUuidForTriggeredRule(Object obj) {
- postMDCInfoForTriggeredRule("" + obj);
+ postMdcInfoForTriggeredRule("" + obj);
}
@@ -864,13 +834,13 @@ public class PolicyLogger {
public static void recordAuditEventStart(String eventId) {
MDC.put(STATUS_CODE, COMPLETE_STATUS);
- postMDCInfoForEvent(eventId);
+ postMdcInfoForEvent(eventId);
if (eventTracker == null) {
eventTracker = new EventTrackInfo();
}
EventData event = new EventData();
- event.setRequestID(eventId);
+ event.setRequestId(eventId);
event.setStartTime(Instant.now());
eventTracker.storeEventData(event);
MDC.put(MDC_KEY_REQUEST_ID, eventId);
@@ -1002,7 +972,7 @@ public class PolicyLogger {
return;
}
- EventData event = eventTracker.getEventDataByRequestID(eventId);
+ EventData event = eventTracker.getEventDataByRequestId(eventId);
if (event != null) {
Instant endTime = event.getEndTime();
@@ -1030,7 +1000,7 @@ public class PolicyLogger {
return;
}
- EventData event = eventTracker.getEventDataByRequestID(eventId.toString());
+ EventData event = eventTracker.getEventDataByRequestId(eventId.toString());
if (event != null) {
Instant endTime = event.getEndTime();
@@ -1065,27 +1035,18 @@ public class PolicyLogger {
MDC.put(MDC_KEY_REQUEST_ID, eventId);
}
- SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
-
- String formatedTime = sdf.format(Date.from(startTime));
- MDC.put(BEGIN_TIME_STAMP, formatedTime);
-
- // set default values for these required fields below, they can be overridden
- formatedTime = sdf.format(Date.from(endTime));
- MDC.put(END_TIME_STAMP, formatedTime);
+ seTimeStamps(startTime, endTime);
MDC.put(RESPONSE_CODE, "N/A");
MDC.put(RESPONSE_DESCRIPTION, "N/A");
long ns = Duration.between(startTime, endTime).toMillis();
- MDC.put(ELAPSED_TIME, Long.toString(ns));
-
auditLogger.info(MessageCodes.RULE_AUDIT_START_END_INFO, MDC.get(MDC_SERVICE_NAME), rule, startTime.toString(),
endTime.toString(), Long.toString(ns), policyVersion);
// --- remove the record from the concurrentHashMap
- if (eventTracker != null && eventTracker.getEventDataByRequestID(eventId) != null) {
+ if (eventTracker != null && eventTracker.getEventDataByRequestId(eventId) != null) {
eventTracker.remove(eventId);
debugLogger.info("eventTracker.remove(" + eventId + ")");
@@ -1258,227 +1219,124 @@ public class PolicyLogger {
*/
public static LoggerType init(Properties properties) {
- Properties loggerProperties;
- if (properties != null) {
- loggerProperties = properties;
- } else {
- System.err.println("PolicyLogger cannot find its configuration - continue");
- loggerProperties = new Properties();
- }
-
- LoggerType loggerType = LoggerType.EELF;
+ Properties loggerProperties = getLoggerProperties(properties);
// fetch and verify definitions of some properties
try {
+ setOverrideLogbackLevels(loggerProperties);
- final int timerDelayTimeProp =
- Integer.parseInt(loggerProperties.getProperty("timer.delay.time", Integer.toString(1000)));
- final int checkIntervalProp =
- Integer.parseInt(loggerProperties.getProperty("check.interval", Integer.toString(30000)));
- final int expiredDateProp =
- Integer.parseInt(loggerProperties.getProperty("event.expired.time", Integer.toString(86400)));
- final int concurrentHashMapLimitProp =
- Integer.parseInt(loggerProperties.getProperty("concurrentHashMap.limit", Integer.toString(5000)));
- final int stopCheckPointProp =
- Integer.parseInt(loggerProperties.getProperty("stop.check.point", Integer.toString(2500)));
- final String loggerTypeProp = loggerProperties.getProperty("logger.type", loggerType.toString());
-
- final String debugLevelProp = loggerProperties.getProperty("debugLogger.level", "INFO");
- final String metricsLevelProp = loggerProperties.getProperty("metricsLogger.level", "ON");
- final String auditLevelProp = loggerProperties.getProperty("audit.level", "ON");
- final String errorLevelProp = loggerProperties.getProperty("error.level", "ON");
- component = loggerProperties.getProperty("policy.component", "DROOLS");
- final String overrideLogbackLevel = loggerProperties.getProperty("override.logback.level.setup");
-
- if (overrideLogbackLevel != null && !overrideLogbackLevel.isEmpty()) {
- if ("TRUE".equalsIgnoreCase(overrideLogbackLevel)) {
- isOverrideLogbackLevel = true;
- } else {
- isOverrideLogbackLevel = false;
- }
- }
-
-
- if (debugLevelProp != null && !debugLevelProp.isEmpty()) {
-
- PolicyLogger.setDebugLevel(Level.valueOf(debugLevelProp));
+ setLoggerLevel(loggerProperties, "debugLogger.level", "INFO", PolicyLogger::setDebugLevel);
- }
- // Only check if it is to turn off or not
- if (errorLevelProp != null && errorLevelProp.equalsIgnoreCase(Level.OFF.toString())) {
-
- PolicyLogger.setErrorLevel(Level.valueOf(errorLevelProp));
+ // Only check if it is to turn on or off
+ setLoggerOnOff(loggerProperties, "metricsLogger.level", PolicyLogger::setMetricsLevel);
+ setLoggerOnOff(loggerProperties, "audit.level", PolicyLogger::setAuditLevel);
+ setLoggerOnOff(loggerProperties, "error.level", PolicyLogger::setErrorLevel);
- }
- // Only check if it is to turn off or not
- if (metricsLevelProp != null && metricsLevelProp.equalsIgnoreCase(Level.OFF.toString())) {
-
- PolicyLogger.setMetricsLevel(Level.valueOf(metricsLevelProp));
-
- }
- // Only check if it is to turn off or not
- if (auditLevelProp != null && auditLevelProp.equalsIgnoreCase(Level.OFF.toString())) {
-
- PolicyLogger.setAuditLevel(Level.valueOf(auditLevelProp));
-
- }
-
- if (isOverrideLogbackLevel) {
-
- debugLogger.setLevel(debugLevel);
- metricsLogger.setLevel(metricsLevel);
- auditLogger.setLevel(auditLevel);
- errorLogger.setLevel(errorLevel);
-
- }
isEventTrackerRunning = false;
- debugLogger.info("timerDelayTime value: " + timerDelayTimeProp);
-
- debugLogger.info("checkInterval value: " + checkIntervalProp);
-
- debugLogger.info("expiredDate value: " + expiredDateProp);
-
- debugLogger.info("concurrentHashMapLimit value: " + concurrentHashMapLimitProp);
-
- debugLogger.info("loggerType value: " + loggerTypeProp);
-
- debugLogger.info("debugLogger level: " + debugLevelProp);
+ timerDelayTime = getIntProp(loggerProperties, "timer.delay.time", timerDelayTime);
+ checkInterval = getIntProp(loggerProperties, "check.interval", checkInterval);
+ expiredTime = getIntProp(loggerProperties, "event.expired.time", expiredTime);
+ concurrentHashMapLimit = getIntProp(loggerProperties, "concurrentHashMap.limit", concurrentHashMapLimit);
+ stopCheckPoint = getIntProp(loggerProperties, "stop.check.point", stopCheckPoint);
+ component = loggerProperties.getProperty("policy.component", "DROOLS");
debugLogger.info("component: " + component);
- if (timerDelayTimeProp > 0) {
-
- timerDelayTime = timerDelayTimeProp;
-
- } else {
- MDC.put(ERROR_CATEGORY, ERROR_CATEGORY_VALUE);
- if (ErrorCodeMap.getErrorCodeInfo(MessageCodes.GENERAL_ERROR) != null) {
- MDC.put(ERROR_CODE, ErrorCodeMap.getErrorCodeInfo(MessageCodes.GENERAL_ERROR).getErrorCode());
- MDC.put(ERROR_DESCRIPTION,
- ErrorCodeMap.getErrorCodeInfo(MessageCodes.GENERAL_ERROR).getErrorDesc());
-
- }
- errorLogger.error("failed to get the timer.delay.time, so use its default value: " + timerDelayTime);
- }
+ return detmLoggerType(loggerProperties);
- if (checkIntervalProp > 0) {
+ } catch (Exception e) {
+ MDC.put(ERROR_CATEGORY, ERROR_CATEGORY_VALUE);
- checkInterval = checkIntervalProp;
+ if (ErrorCodeMap.getErrorCodeInfo(MessageCodes.GENERAL_ERROR) != null) {
+ MDC.put(ERROR_CODE, ErrorCodeMap.getErrorCodeInfo(MessageCodes.GENERAL_ERROR).getErrorCode());
+ MDC.put(ERROR_DESCRIPTION, ErrorCodeMap.getErrorCodeInfo(MessageCodes.GENERAL_ERROR).getErrorDesc());
- } else {
- MDC.put(ERROR_CATEGORY, ERROR_CATEGORY_VALUE);
- if (ErrorCodeMap.getErrorCodeInfo(MessageCodes.GENERAL_ERROR) != null) {
- MDC.put(ERROR_CODE, ErrorCodeMap.getErrorCodeInfo(MessageCodes.GENERAL_ERROR).getErrorCode());
- MDC.put(ERROR_DESCRIPTION,
- ErrorCodeMap.getErrorCodeInfo(MessageCodes.GENERAL_ERROR).getErrorDesc());
-
- }
- errorLogger.error("failed to get the check.interval, so use its default value: " + checkInterval);
}
+ errorLogger.error("failed to get the policyLogger.properties, so use their default values", e);
- if (expiredDateProp > 0) {
-
- expiredTime = expiredDateProp;
-
- } else {
- MDC.put(ERROR_CATEGORY, ERROR_CATEGORY_VALUE);
-
- if (ErrorCodeMap.getErrorCodeInfo(MessageCodes.GENERAL_ERROR) != null) {
- MDC.put(ERROR_CODE, ErrorCodeMap.getErrorCodeInfo(MessageCodes.GENERAL_ERROR).getErrorCode());
- MDC.put(ERROR_DESCRIPTION,
- ErrorCodeMap.getErrorCodeInfo(MessageCodes.GENERAL_ERROR).getErrorDesc());
-
- }
- errorLogger.error("failed to get the event.expired.time, so use its default value: " + expiredTime);
- }
+ return LoggerType.EELF;
+ }
- if (concurrentHashMapLimitProp > 0) {
+ }
- concurrentHashMapLimit = concurrentHashMapLimitProp;
+ private static int getIntProp(Properties properties, String propName, int defaultValue) {
+ final int propValue = Integer.parseInt(properties.getProperty(propName, String.valueOf(defaultValue)));
- } else {
- MDC.put(ERROR_CATEGORY, ERROR_CATEGORY_VALUE);
- if (ErrorCodeMap.getErrorCodeInfo(MessageCodes.GENERAL_ERROR) != null) {
- MDC.put(ERROR_CODE, ErrorCodeMap.getErrorCodeInfo(MessageCodes.GENERAL_ERROR).getErrorCode());
- MDC.put(ERROR_DESCRIPTION,
- ErrorCodeMap.getErrorCodeInfo(MessageCodes.GENERAL_ERROR).getErrorDesc());
-
- }
- errorLogger.error("failed to get the concurrentHashMap.limit, so use its default value: "
- + concurrentHashMapLimit);
- }
+ debugLogger.info(propName + " value: " + propValue);
- if (stopCheckPointProp > 0) {
+ if (propValue > 0) {
+ return propValue;
- stopCheckPoint = stopCheckPointProp;
+ } else {
+ MDC.put(ERROR_CATEGORY, ERROR_CATEGORY_VALUE);
+ if (ErrorCodeMap.getErrorCodeInfo(MessageCodes.GENERAL_ERROR) != null) {
+ MDC.put(ERROR_CODE, ErrorCodeMap.getErrorCodeInfo(MessageCodes.GENERAL_ERROR).getErrorCode());
+ MDC.put(ERROR_DESCRIPTION,
+ ErrorCodeMap.getErrorCodeInfo(MessageCodes.GENERAL_ERROR).getErrorDesc());
- } else {
- MDC.put(ERROR_CATEGORY, ERROR_CATEGORY_VALUE);
- if (ErrorCodeMap.getErrorCodeInfo(MessageCodes.GENERAL_ERROR) != null) {
- MDC.put(ERROR_CODE, ErrorCodeMap.getErrorCodeInfo(MessageCodes.GENERAL_ERROR).getErrorCode());
- MDC.put(ERROR_DESCRIPTION,
- ErrorCodeMap.getErrorCodeInfo(MessageCodes.GENERAL_ERROR).getErrorDesc());
-
- }
- errorLogger.error("failed to get the stop.check.point, so use its default value: " + stopCheckPoint);
}
+ errorLogger.error("failed to get the " + propName + ", so use its default value: " + defaultValue);
+ return defaultValue;
+ }
+ }
- if (loggerTypeProp != null) {
-
- if ("EELF".equalsIgnoreCase(loggerTypeProp)) {
-
- loggerType = LoggerType.EELF;
-
- } else if ("LOG4J".equalsIgnoreCase(loggerTypeProp)) {
-
- loggerType = LoggerType.LOG4J;
-
- } else if ("SYSTEMOUT".equalsIgnoreCase(loggerTypeProp)) {
-
- loggerType = LoggerType.SYSTEMOUT;
+ private static Properties getLoggerProperties(Properties properties) {
+ if (properties != null) {
+ return properties;
+ } else {
+ displayErrorMessage("PolicyLogger cannot find its configuration - continue");
+ return new Properties();
+ }
+ }
- }
+ private static void setLoggerLevel(Properties properties, String propName, String defaultValue,
+ Consumer<String> setter) {
- }
+ final String propValue = properties.getProperty(propName, defaultValue);
- if (debugLevelProp != null && !debugLevelProp.isEmpty()) {
+ if (!StringUtils.isBlank(propValue)) {
+ debugLogger.info(propName + " level: " + propValue);
+ }
- debugLevel = Level.valueOf(debugLevelProp);
+ setter.accept(propValue);
+ }
- }
- // Only check if it is to turn off or not
- if (errorLevelProp != null && errorLevelProp.equalsIgnoreCase(Level.OFF.toString())) {
+ private static void setLoggerOnOff(Properties properties, String propName, Consumer<String> setter) {
+ final String propValue = properties.getProperty(propName, "ON");
- errorLevel = Level.valueOf(errorLevelProp);
+ if (Level.OFF.toString().equalsIgnoreCase(propValue)) {
+ debugLogger.info(propName + " level: " + propValue);
+ }
- }
- // Only check if it is to turn off or not
- if (metricsLevelProp != null && metricsLevelProp.equalsIgnoreCase(Level.OFF.toString())) {
+ setter.accept(propValue);
+ }
- metricsLevel = Level.valueOf(metricsLevelProp);
+ private static void setOverrideLogbackLevels(Properties loggerProperties) {
+ final String overrideLogbackLevel = loggerProperties.getProperty("override.logback.level.setup");
- }
- // Only check if it is to turn off or not
- if (auditLevelProp != null && auditLevelProp.equalsIgnoreCase(Level.OFF.toString())) {
+ if (!StringUtils.isBlank(overrideLogbackLevel)) {
+ isOverrideLogbackLevel = "TRUE".equalsIgnoreCase(overrideLogbackLevel);
+ }
+ }
- auditLevel = Level.valueOf(auditLevelProp);
+ private static LoggerType detmLoggerType(Properties loggerProperties) {
+ final String loggerTypeProp = loggerProperties.getProperty("logger.type", LoggerType.EELF.toString());
+ debugLogger.info("loggerType value: " + loggerTypeProp);
- }
+ switch (loggerTypeProp.toUpperCase()) {
+ case "EELF":
+ return LoggerType.EELF;
- } catch (Exception e) {
- MDC.put(ERROR_CATEGORY, ERROR_CATEGORY_VALUE);
+ case "LOG4J":
+ return LoggerType.LOG4J;
- if (ErrorCodeMap.getErrorCodeInfo(MessageCodes.GENERAL_ERROR) != null) {
- MDC.put(ERROR_CODE, ErrorCodeMap.getErrorCodeInfo(MessageCodes.GENERAL_ERROR).getErrorCode());
- MDC.put(ERROR_DESCRIPTION, ErrorCodeMap.getErrorCodeInfo(MessageCodes.GENERAL_ERROR).getErrorDesc());
+ case "SYSTEMOUT":
+ return LoggerType.SYSTEMOUT;
- }
- errorLogger.error("failed to get the policyLogger.properties, so use their default values", e);
+ default:
+ return LoggerType.EELF;
}
-
- return loggerType;
-
}
@@ -1505,5 +1363,4 @@ public class PolicyLogger {
public static void setServerInfo(String serverHost, String serverPort) {
MDC.put(SERVER_NAME, serverHost + ":" + serverPort);
}
-
}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/DisplayUtils.java b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/DisplayUtils.java
new file mode 100644
index 00000000..dc740440
--- /dev/null
+++ b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/DisplayUtils.java
@@ -0,0 +1,41 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.logging.flexlogger;
+
+/**
+ * Utilities to display messages. These are generally used while logging is being
+ * configured, or when logging being directed to System.out. As a result, it directly
+ * writes to System.out rather than to a logger.
+ */
+public class DisplayUtils {
+
+ private DisplayUtils() {
+ // do nothing
+ }
+
+ public static void displayMessage(Object message) {
+ System.out.println(message);
+ }
+
+ public static void displayErrorMessage(Object msg) {
+ System.err.println(msg);
+ }
+}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/EelfLogger.java b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/EelfLogger.java
index e0c4144b..a3e5cc8f 100644
--- a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/EelfLogger.java
+++ b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/EelfLogger.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP-Logging
* ================================================================================
- * 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.
@@ -40,31 +40,31 @@ public class EelfLogger implements Logger, Serializable {
/**
* Constructor.
- *
+ *
* @param clazz the class
*/
public EelfLogger(Class<?> clazz) {
if (clazz != null) {
className = clazz.getName();
}
- PolicyLogger.postMDCInfoForEvent(null);
+ PolicyLogger.postMdcInfoForEvent(null);
}
/**
* Constructor.
- *
+ *
* @param className the class name
*/
public EelfLogger(String className) {
if (className != null) {
this.className = className;
}
- PolicyLogger.postMDCInfoForEvent(null);
+ PolicyLogger.postMdcInfoForEvent(null);
}
/**
* Constructor.
- *
+ *
* @param clazz the class
* @param isNewTransaction is a new transaction
*/
@@ -73,7 +73,7 @@ public class EelfLogger implements Logger, Serializable {
className = clazz.getName();
}
if (isNewTransaction) {
- transId = PolicyLogger.postMDCInfoForEvent(null);
+ transId = PolicyLogger.postMdcInfoForEvent(null);
} else {
transId = PolicyLogger.getTransId();
}
@@ -81,7 +81,7 @@ public class EelfLogger implements Logger, Serializable {
/**
* Constructor.
- *
+ *
* @param className the class name
* @param isNewTransaction is a new transaction
*/
@@ -90,7 +90,7 @@ public class EelfLogger implements Logger, Serializable {
this.className = className;
}
if (isNewTransaction) {
- transId = PolicyLogger.postMDCInfoForEvent(null);
+ transId = PolicyLogger.postMdcInfoForEvent(null);
} else {
transId = PolicyLogger.getTransId();
}
@@ -98,7 +98,7 @@ public class EelfLogger implements Logger, Serializable {
/**
* Constructor.
- *
+ *
* @param clazz the class
* @param transId the transaction ID
*/
@@ -106,13 +106,13 @@ public class EelfLogger implements Logger, Serializable {
if (clazz != null) {
className = clazz.getName();
}
- PolicyLogger.postMDCInfoForEvent(transId);
+ PolicyLogger.postMdcInfoForEvent(transId);
this.transId = transId;
}
/**
* Constructor.
- *
+ *
* @param className the class name
* @param transId the transaction ID
*/
@@ -120,13 +120,13 @@ public class EelfLogger implements Logger, Serializable {
if (className != null) {
this.className = className;
}
- PolicyLogger.postMDCInfoForEvent(transId);
+ PolicyLogger.postMdcInfoForEvent(transId);
this.transId = transId;
}
/**
* Sets transaction Id for logging.
- *
+ *
* @param transId the transaction ID
*/
@Override
@@ -146,7 +146,7 @@ public class EelfLogger implements Logger, Serializable {
/**
* Records a message.
- *
+ *
* @param message the message
*/
@Override
@@ -156,7 +156,7 @@ public class EelfLogger implements Logger, Serializable {
/**
* Records a message.
- *
+ *
* @param message the message
* @param throwable the throwable
*/
@@ -167,7 +167,7 @@ public class EelfLogger implements Logger, Serializable {
/**
* Records an error message.
- *
+ *
* @param message the message
*/
@Override
@@ -177,7 +177,7 @@ public class EelfLogger implements Logger, Serializable {
/**
* Records an error message.
- *
+ *
* @param message the message
* @param throwable the throwable
*/
@@ -188,7 +188,7 @@ public class EelfLogger implements Logger, Serializable {
/**
* Records an error message.
- *
+ *
* @param msg the message code
* @param throwable the throwable
* @param arguments the messages
@@ -200,7 +200,7 @@ public class EelfLogger implements Logger, Serializable {
/**
* Records an error message.
- *
+ *
* @param msg the message code
* @param arguments the messages
*/
@@ -211,7 +211,7 @@ public class EelfLogger implements Logger, Serializable {
/**
* Records a message.
- *
+ *
* @param message the message
*/
@Override
@@ -221,7 +221,7 @@ public class EelfLogger implements Logger, Serializable {
/**
* Records a message.
- *
+ *
* @param message the message
* @param throwable the throwable
*/
@@ -232,7 +232,7 @@ public class EelfLogger implements Logger, Serializable {
/**
* Records a message.
- *
+ *
* @param message the message
*/
@Override
@@ -242,7 +242,7 @@ public class EelfLogger implements Logger, Serializable {
/**
* Records a message.
- *
+ *
* @param message the message
* @param throwable the throwable
*/
@@ -253,7 +253,7 @@ public class EelfLogger implements Logger, Serializable {
/**
* Records a message.
- *
+ *
* @param msg the message codes
* @param arguments the messages
*/
@@ -264,7 +264,7 @@ public class EelfLogger implements Logger, Serializable {
/**
* Records a message.
- *
+ *
* @param msg the message
* @param throwable the throwable
* @param arguments the messages
@@ -276,7 +276,7 @@ public class EelfLogger implements Logger, Serializable {
/**
* Records a message.
- *
+ *
* @param message the message
*/
@Override
@@ -286,7 +286,7 @@ public class EelfLogger implements Logger, Serializable {
/**
* Records a message.
- *
+ *
* @param message the message
* @param throwable the throwable
*/
@@ -297,7 +297,7 @@ public class EelfLogger implements Logger, Serializable {
/**
* Returns true for debug enabled, or false for not.
- *
+ *
* @return boolean
*/
@Override
@@ -307,7 +307,7 @@ public class EelfLogger implements Logger, Serializable {
/**
* Returns true for info enabled, or false for not.
- *
+ *
* @return boolean
*/
@Override
@@ -317,7 +317,7 @@ public class EelfLogger implements Logger, Serializable {
/**
* Returns true for warn enabled, or false for not.
- *
+ *
* @return boolean
*/
@Override
@@ -327,7 +327,7 @@ public class EelfLogger implements Logger, Serializable {
/**
* Returns true for error enabled, or false for not.
- *
+ *
* @return boolean
*/
@Override
@@ -337,7 +337,7 @@ public class EelfLogger implements Logger, Serializable {
/**
* Returns true for audit enabled, or false for not.
- *
+ *
* @return boolean
*/
@Override
@@ -347,7 +347,7 @@ public class EelfLogger implements Logger, Serializable {
/**
* Returns true for metrics enabled, or false for not.
- *
+ *
* @return boolean
*/
@Override
@@ -357,7 +357,7 @@ public class EelfLogger implements Logger, Serializable {
/**
* Returns true for trace enabled, or false for not.
- *
+ *
* @return boolean
*/
@Override
@@ -367,7 +367,7 @@ public class EelfLogger implements Logger, Serializable {
/**
* Records an audit message.
- *
+ *
* @param arg0 the message
*/
@Override
@@ -377,7 +377,7 @@ public class EelfLogger implements Logger, Serializable {
/**
* Records an audit message.
- *
+ *
* @param message the message
* @param throwable the throwable
*/
@@ -388,7 +388,7 @@ public class EelfLogger implements Logger, Serializable {
/**
* Records an audit message.
- *
+ *
* @param eventId the event ID
*/
@Override
@@ -398,7 +398,7 @@ public class EelfLogger implements Logger, Serializable {
/**
* Records an audit message.
- *
+ *
* @param eventId the event ID
*/
@Override
@@ -408,7 +408,7 @@ public class EelfLogger implements Logger, Serializable {
/**
* Records an audit message.
- *
+ *
* @param eventId the event ID
* @param rule the rule
* @param policyVersion the policy cersion
@@ -420,7 +420,7 @@ public class EelfLogger implements Logger, Serializable {
/**
* Records an audit message.
- *
+ *
* @param eventId the event ID
* @param rule the rule
* @param policyVersion the policy version
@@ -432,7 +432,7 @@ public class EelfLogger implements Logger, Serializable {
/**
* Records an audit message.
- *
+ *
* @param eventId the event ID
* @param rule the rule
*/
@@ -443,7 +443,7 @@ public class EelfLogger implements Logger, Serializable {
/**
* Records an audit message.
- *
+ *
* @param eventId the event ID
* @param rule the rule
*/
@@ -454,7 +454,7 @@ public class EelfLogger implements Logger, Serializable {
/**
* Records a metrics message.
- *
+ *
* @param eventId the event ID
* @param message the message
*/
@@ -465,7 +465,7 @@ public class EelfLogger implements Logger, Serializable {
/**
* Records a metrics message.
- *
+ *
* @param eventId the event ID
* @param message the message
*/
@@ -476,7 +476,7 @@ public class EelfLogger implements Logger, Serializable {
/**
* Records a metrics message.
- *
+ *
* @param message the message
*/
@Override
@@ -486,32 +486,32 @@ public class EelfLogger implements Logger, Serializable {
/**
* Populates MDC Info.
- *
+ *
* @param transId the transaction ID
*/
@Override
- public String postMDCInfoForEvent(String transId) {
- return PolicyLogger.postMDCInfoForEvent(transId);
+ public String postMdcInfoForEvent(String transId) {
+ return PolicyLogger.postMdcInfoForEvent(transId);
}
/**
* Populates MDC Info.
- *
+ *
* @param obj the object
*/
@Override
- public void postMDCInfoForEvent(Object obj) {
- PolicyLogger.postMDCInfoForEvent(obj);
+ public void postMdcInfoForEvent(Object obj) {
+ PolicyLogger.postMdcInfoForEvent(obj);
}
/**
* Populates MDC Info for the rule triggered.
- *
+ *
* @param transId the transaction ID
*/
@Override
- public void postMDCInfoForTriggeredRule(String transId) {
- PolicyLogger.postMDCInfoForTriggeredRule(transId);
+ public void postMdcInfoForTriggeredRule(String transId) {
+ PolicyLogger.postMdcInfoForTriggeredRule(transId);
}
}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/FlexLogger.java b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/FlexLogger.java
index 90240a77..030363dc 100644
--- a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/FlexLogger.java
+++ b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/FlexLogger.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP-Logging
* ================================================================================
- * 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.
@@ -20,6 +20,8 @@
package org.onap.policy.common.logging.flexlogger;
+import static org.onap.policy.common.logging.flexlogger.DisplayUtils.displayMessage;
+
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.time.Instant;
@@ -49,12 +51,12 @@ public class FlexLogger extends SecurityManager {
/**
* Returns an instance of Logger.
- *
+ *
* @param clazz the class
*/
public static Logger getLogger(Class<?> clazz) {
Logger logger = null;
- System.out.println(GET_LOGGER_PREFIX + loggerType);
+ displayMessage(GET_LOGGER_PREFIX + loggerType);
switch (loggerType) {
case EELF:
@@ -75,12 +77,12 @@ public class FlexLogger extends SecurityManager {
/**
* Returns an instance of Logger.
- *
+ *
* @param name the name of the logger
*/
public static Logger getLogger(String name) {
Logger logger = null;
- System.out.println(GET_LOGGER_PREFIX + loggerType);
+ displayMessage(GET_LOGGER_PREFIX + loggerType);
switch (loggerType) {
case EELF:
@@ -101,13 +103,13 @@ public class FlexLogger extends SecurityManager {
/**
* Returns an instance of Logger.
- *
+ *
* @param clazz the class
* @param isNewTransaction is a new transaction
*/
public static Logger getLogger(Class<?> clazz, boolean isNewTransaction) {
Logger logger = null;
- System.out.println(GET_LOGGER_PREFIX + loggerType);
+ displayMessage(GET_LOGGER_PREFIX + loggerType);
switch (loggerType) {
case EELF:
@@ -128,13 +130,13 @@ public class FlexLogger extends SecurityManager {
/**
* Returns an instance of Logger.
- *
+ *
* @param name the name of the logger
* @param isNewTransaction is a new transaction
*/
public static Logger getLogger(String name, boolean isNewTransaction) {
Logger logger = null;
- System.out.println(GET_LOGGER_PREFIX + loggerType);
+ displayMessage(GET_LOGGER_PREFIX + loggerType);
switch (loggerType) {
case EELF:
@@ -156,7 +158,7 @@ public class FlexLogger extends SecurityManager {
* Returns the calling class name.
*/
public String getClassName() {
- System.out.println("getClassContext()[3].getName() " + getClassContext()[3].getName());
+ displayMessage("getClassContext()[3].getName() " + getClassContext()[3].getName());
return getClassContext()[3].getName();
}
@@ -177,7 +179,7 @@ public class FlexLogger extends SecurityManager {
/**
* Returns an instance of Logger4J.
- *
+ *
* @param name the name of the logger
*/
private static Logger4J getLog4JLogger(String name) {
@@ -193,7 +195,7 @@ public class FlexLogger extends SecurityManager {
/**
* Returns an instance of EelfLogger.
- *
+ *
* @param clazz the class
* @param isNewTransaction is a new transaction
*/
@@ -218,11 +220,11 @@ public class FlexLogger extends SecurityManager {
}
// installl already created but it is new transaction
if (isNewTransaction) {
- String transId = PolicyLogger.postMDCInfoForEvent(null);
+ String transId = PolicyLogger.postMdcInfoForEvent(null);
logger.setTransId(transId);
}
}
- System.out.println("eelfLoggerMap size : " + eelfLoggerMap.size() + " class name: " + className);
+ displayMessage("eelfLoggerMap size : " + eelfLoggerMap.size() + " class name: " + className);
return logger;
}
@@ -246,37 +248,24 @@ public class FlexLogger extends SecurityManager {
*/
private static LoggerType initlogger() {
LoggerType loggerType = LoggerType.EELF;
- String overrideLogbackLevel = "FALSE";
- String loggerTypeString = "";
Properties properties = null;
try {
properties = PropertyUtil.getProperties("config/policyLogger.properties");
- System.out.println("FlexLogger:properties => " + properties);
+ displayMessage("FlexLogger:properties => " + properties);
if (properties != null) {
- overrideLogbackLevel = properties.getProperty("override.logback.level.setup");
- System.out.println("FlexLogger:overrideLogbackLevel => " + overrideLogbackLevel);
- loggerTypeString = properties.getProperty("logger.type");
- if (loggerTypeString != null) {
- if ("EELF".equalsIgnoreCase(loggerTypeString)) {
- loggerType = LoggerType.EELF;
- if ("TRUE".equalsIgnoreCase(overrideLogbackLevel)) {
- System.out.println("FlexLogger: start listener.");
- properties = PropertyUtil.getProperties("config/policyLogger.properties",
- new PropertiesCallBack("FlexLogger-CallBack"));
- }
- } else if ("LOG4J".equalsIgnoreCase(loggerTypeString)) {
- loggerType = LoggerType.LOG4J;
- } else if ("SYSTEMOUT".equalsIgnoreCase(loggerTypeString)) {
- loggerType = LoggerType.SYSTEMOUT;
- }
-
- System.out.println("FlexLogger.logger_Type value: " + loggerTypeString);
+ String overrideLogbackLevel = properties.getProperty("override.logback.level.setup");
+ displayMessage("FlexLogger:overrideLogbackLevel => " + overrideLogbackLevel);
+ String loggerTypeString = properties.getProperty("logger.type");
+ if ("EELF".equalsIgnoreCase(loggerTypeString) && "TRUE".equalsIgnoreCase(overrideLogbackLevel)) {
+ displayMessage("FlexLogger: start listener.");
+ properties = PropertyUtil.getProperties("config/policyLogger.properties",
+ new PropertiesCallBack("FlexLogger-CallBack"));
}
}
} catch (IOException e1) {
- System.out.println("initlogger" + e1);
+ displayMessage("initlogger" + e1);
} finally {
// OK to pass no properties (null)
loggerType = PolicyLogger.init(properties);
@@ -309,8 +298,8 @@ public class FlexLogger extends SecurityManager {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS+00:00");
Instant startTime = Instant.now();
String formatedTime = sdf.format(Date.from(startTime));
- System.out.println("FlexLogger.propertiesChanged : called at time : " + formatedTime);
- System.out.println("FlexLogger.propertiesChanged : debugLevel : " + debugLevel);
+ displayMessage("FlexLogger.propertiesChanged : called at time : " + formatedTime);
+ displayMessage("FlexLogger.propertiesChanged : debugLevel : " + debugLevel);
if (changedKeys != null) {
@@ -332,5 +321,4 @@ public class FlexLogger extends SecurityManager {
}
}
}
-
}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/Logger.java b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/Logger.java
index f74aca14..d6f020e0 100644
--- a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/Logger.java
+++ b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/Logger.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP-Logging
* ================================================================================
- * 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.
@@ -195,12 +195,12 @@ public interface Logger {
/**
* Populates MDC info.
*/
- public String postMDCInfoForEvent(String transId);
+ public String postMdcInfoForEvent(String transId);
/**
* Populates MDC Info.
*/
- public void postMDCInfoForEvent(Object obj);
+ public void postMdcInfoForEvent(Object obj);
/**
* Sets transaction Id.
@@ -215,6 +215,6 @@ public interface Logger {
/**
* Populates MDC Info for the rule triggered.
*/
- public void postMDCInfoForTriggeredRule(String transId);
+ public void postMdcInfoForTriggeredRule(String transId);
}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/Logger4J.java b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/Logger4J.java
index 88d3800a..8802d17e 100644
--- a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/Logger4J.java
+++ b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/Logger4J.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP-Logging
* ================================================================================
- * 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.
@@ -20,6 +20,8 @@
package org.onap.policy.common.logging.flexlogger;
+import static org.onap.policy.common.logging.flexlogger.DisplayUtils.displayMessage;
+
import com.att.eelf.configuration.EELFLogger.Level;
import java.io.IOException;
@@ -47,11 +49,11 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge
/**
* Constructor.
- *
+ *
* @param clazz the class
*/
public Logger4J(Class<?> clazz) {
- System.out.println("create instance of Logger4J");
+ displayMessage("create instance of Logger4J");
if (clazz != null) {
log = Logger.getLogger(clazz);
className = clazz.getName();
@@ -60,12 +62,12 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge
/**
* Constructor.
- *
+ *
* @param name the name of the logger
* @param className the name of the class
*/
public Logger4J(String name, String className) {
- System.out.println("create instance of Logger4J");
+ displayMessage("create instance of Logger4J");
if (name != null) {
log = Logger.getLogger(name);
}
@@ -91,7 +93,7 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge
/**
* Records a message.
- *
+ *
* @param message the message
*/
@Override
@@ -103,7 +105,7 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge
/**
* Records a message.
- *
+ *
* @param message the message
* @param throwable the throwable
*/
@@ -114,7 +116,7 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge
/**
* Records an error message.
- *
+ *
* @param message the message
*/
@Override
@@ -124,7 +126,7 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge
/**
* Records an error message.
- *
+ *
* @param message the message
* @param throwable the throwable
*/
@@ -135,7 +137,7 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge
/**
* Records an error message.
- *
+ *
* @param msg the message code
* @param throwable the throwable
* @param arguments the messages
@@ -148,7 +150,7 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge
/**
* Records an error message.
- *
+ *
* @param msg the message code
* @param arguments the messages
*/
@@ -159,7 +161,7 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge
/**
* Records a message.
- *
+ *
* @param message the message
*/
@Override
@@ -169,7 +171,7 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge
/**
* Records a message.
- *
+ *
* @param message the message
* @param throwable the throwable
*/
@@ -180,7 +182,7 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge
/**
* Records a message.
- *
+ *
* @param message the message
*/
@Override
@@ -190,7 +192,7 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge
/**
* Records a message.
- *
+ *
* @param message the message
* @param throwable the throwable
*/
@@ -201,7 +203,7 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge
/**
* Records a message.
- *
+ *
* @param msg the message code
* @param arguments the messages
*/
@@ -212,7 +214,7 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge
/**
* Records a message.
- *
+ *
* @param msg the message code
* @param throwable the throwable
* @param arguments the messages
@@ -224,7 +226,7 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge
/**
* Records a message.
- *
+ *
* @param message the message
*/
@Override
@@ -234,7 +236,7 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge
/**
* Records a message.
- *
+ *
* @param message the message
* @param throwable the throwable
*/
@@ -245,7 +247,7 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge
/**
* Returns true for debug enabled, or false for not.
- *
+ *
* @return boolean
*/
@Override
@@ -255,7 +257,7 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge
/**
* Returns true for error enabled, or false for not.
- *
+ *
* @return boolean
*/
@SuppressWarnings("deprecation")
@@ -266,7 +268,7 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge
/**
* Returns true for info enabled, or false for not.
- *
+ *
* @return boolean
*/
@Override
@@ -276,7 +278,7 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge
/**
* Returns true for warn enabled, or false for not.
- *
+ *
* @return boolean
*/
@SuppressWarnings("deprecation")
@@ -288,7 +290,7 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge
/**
* Returns true for audit enabled, or false for not.
- *
+ *
* @return boolean
*/
@Override
@@ -298,7 +300,7 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge
/**
* Returns true for metrics enabled, or false for not.
- *
+ *
* @return boolean
*/
@Override
@@ -308,7 +310,7 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge
/**
* Records an audit message.
- *
+ *
* @param message the message
*/
@Override
@@ -318,7 +320,7 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge
/**
* Records an audit message.
- *
+ *
* @param message the message
* @param throwable the throwable
*/
@@ -330,7 +332,7 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge
/**
* Records an audit message.
- *
+ *
* @param eventId the event ID
*/
@Override
@@ -340,7 +342,7 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge
/**
* Records an audit message.
- *
+ *
* @param eventId the event ID
*/
@Override
@@ -352,7 +354,7 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge
/**
* Records an audit message.
- *
+ *
* @param eventId the event ID
* @param rule the rule
* @param policyVersion the policy version
@@ -364,7 +366,7 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge
/**
* Records an audit message.
- *
+ *
* @param eventId the event ID
* @param rule the rule
* @param policyVersion the policy version
@@ -380,7 +382,7 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge
/**
* Records an audit message.
- *
+ *
* @param eventId the event ID
* @param rule the rule
*/
@@ -391,7 +393,7 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge
/**
* Records an audit message.
- *
+ *
* @param eventId the event ID
* @param rule the rule
*/
@@ -406,7 +408,7 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge
/**
* Records a metrics message.
- *
+ *
* @param eventId the event ID
* @param message the message
*/
@@ -418,7 +420,7 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge
/**
* Records a metrics message.
- *
+ *
* @param eventId the event ID
* @param message the message
*/
@@ -433,7 +435,7 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge
/**
* Records a metrics message.
- *
+ *
* @param message the message
*/
@Override
@@ -443,11 +445,11 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge
/**
* Returns transaction Id.
- *
+ *
* @param transId the transaction ID
*/
@Override
- public String postMDCInfoForEvent(String transId) {
+ public String postMdcInfoForEvent(String transId) {
String transactionId = transId;
if (transactionId == null || transactionId.isEmpty()) {
transactionId = UUID.randomUUID().toString();
@@ -458,17 +460,17 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge
/**
* Records transaction Id.
- *
+ *
* @param message the message
*/
@Override
- public void postMDCInfoForEvent(Object message) {
+ public void postMdcInfoForEvent(Object message) {
log.info(message);
}
/**
* Returns true for trace enabled, or false for not.
- *
+ *
* @return boolean
*/
@Override
@@ -478,11 +480,11 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge
/**
* Records transaction Id.
- *
+ *
* @param transId the transaction ID
*/
@Override
- public void postMDCInfoForTriggeredRule(String transId) {
+ public void postMdcInfoForTriggeredRule(String transId) {
log.info(transId);
}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/PropertyUtil.java b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/PropertyUtil.java
index 9d9165ef..38759bc2 100644
--- a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/PropertyUtil.java
+++ b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/PropertyUtil.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP-Logging
* ================================================================================
- * 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.
@@ -20,6 +20,8 @@
package org.onap.policy.common.logging.flexlogger;
+import static org.onap.policy.common.logging.flexlogger.DisplayUtils.displayErrorMessage;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -36,7 +38,7 @@ import java.util.TimerTask;
* notifications of future changes.
*/
public class PropertyUtil {
-
+
protected static class LazyHolder {
/**
* Timer thread. Will not be allocated by the JVM until it is first referenced.
@@ -50,7 +52,7 @@ public class PropertyUtil {
/**
* Read in a properties file.
- *
+ *
* @param file the properties file
* @return a Properties object, containing the associated properties
* @throws IOException - subclass 'FileNotFoundException' if the file does not exist or can't be
@@ -74,7 +76,7 @@ public class PropertyUtil {
/**
* Read in a properties file.
- *
+ *
* @param fileName the properties file
* @return a Properties object, containing the associated properties
* @throws IOException - subclass 'FileNotFoundException' if the file does not exist or can't be
@@ -94,7 +96,7 @@ public class PropertyUtil {
public interface Listener {
/**
* Notification of a properties file change.
- *
+ *
* @param properties the new properties
* @param changedKeys the set of property names that have changed, including additions and
* removals
@@ -150,7 +152,7 @@ public class PropertyUtil {
try {
poll();
} catch (Exception e) {
- System.err.println(e);
+ displayErrorMessage(e);
}
}
};
@@ -159,7 +161,7 @@ public class PropertyUtil {
/**
* Add a listener to the notification list.
- *
+ *
* @param listener this is the listener to add to the list
* @return the properties at the moment the listener was added to the list
*/
@@ -170,7 +172,7 @@ public class PropertyUtil {
/**
* Remove a listener from the notification list.
- *
+ *
* @param listener this is the listener to remove
*/
synchronized void removeListener(Listener listener) {
@@ -190,7 +192,7 @@ public class PropertyUtil {
/**
* This method is periodically called to check for property list updates.
- *
+ *
* @throws IOException if there is an error in reading the properties file
*/
synchronized void poll() throws IOException {
@@ -308,7 +310,7 @@ public class PropertyUtil {
/**
* Stop listenening for updates.
- *
+ *
* @param file the properties file
* @param listener notify if not null, this is a callback interface that was used for
* notifications of changes
@@ -325,7 +327,7 @@ public class PropertyUtil {
/**
* Stop listenening for updates.
- *
+ *
* @param fileName the properties file
* @param listener notify if not null, this is a callback interface that was used for
* notifications of changes
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/SystemOutLogger.java b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/SystemOutLogger.java
index 70ad08ae..f7a68a3d 100644
--- a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/SystemOutLogger.java
+++ b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/SystemOutLogger.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP-Logging
* ================================================================================
- * 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.
@@ -20,6 +20,8 @@
package org.onap.policy.common.logging.flexlogger;
+import static org.onap.policy.common.logging.flexlogger.DisplayUtils.displayMessage;
+
import com.att.eelf.configuration.EELFLogger.Level;
import java.io.Serializable;
@@ -46,11 +48,11 @@ public class SystemOutLogger implements Logger, Serializable {
/**
* Constructor.
- *
+ *
* @param clazz the class
*/
public SystemOutLogger(Class<?> clazz) {
- System.out.println("create instance of SystemOutLogger");
+ displayMessage("create instance of SystemOutLogger");
if (clazz != null) {
className = clazz.getName();
}
@@ -59,11 +61,11 @@ public class SystemOutLogger implements Logger, Serializable {
/**
* Constructor.
- *
+ *
* @param className the class name
*/
public SystemOutLogger(String className) {
- System.out.println("create instance of SystemOutLogger");
+ displayMessage("create instance of SystemOutLogger");
if (className != null) {
this.className = className;
}
@@ -114,7 +116,7 @@ public class SystemOutLogger implements Logger, Serializable {
@Override
public void setTransId(String transId) {
- System.out.println(transId);
+ displayMessage(transId);
this.transId = transId;
}
@@ -129,129 +131,129 @@ public class SystemOutLogger implements Logger, Serializable {
/**
* Records a message.
- *
+ *
* @param message the message
*/
@Override
public void debug(Object message) {
- System.out.println(transId + "|" + className + " : " + message);
+ displayMessage(transId + "|" + className + " : " + message);
}
/**
* Records a message.
- *
+ *
* @param message the message
* @param throwable the throwable
*/
@Override
public void debug(Object message, Throwable throwable) {
- System.out.println(transId + "|" + className + " : " + message + ":" + throwable);
+ displayMessage(transId + "|" + className + " : " + message + ":" + throwable);
}
/**
* Records an error message.
- *
+ *
* @param message the message
*/
@Override
public void error(Object message) {
- System.out.println(transId + "|" + className + " : " + message);
+ displayMessage(transId + "|" + className + " : " + message);
}
/**
* Records an error message.
- *
+ *
* @param message the message
* @param throwable the throwable
*/
@Override
public void error(Object message, Throwable throwable) {
- System.out.println(transId + "|" + className + " : " + message + ":" + throwable);
+ displayMessage(transId + "|" + className + " : " + message + ":" + throwable);
}
/**
* Records an error message.
- *
+ *
* @param msg the message code
* @param throwable the throwable
* @param arguments the messages
*/
@Override
public void error(MessageCodes msg, Throwable throwable, String... arguments) {
- System.out.println(className + " : " + "MessageCodes :" + msg + Arrays.asList(arguments));
+ displayMessage(className + " : " + "MessageCodes :" + msg + Arrays.asList(arguments));
}
/**
* Records an error message.
- *
+ *
* @param msg the message code
* @param arguments the messages
*/
@Override
public void error(MessageCodes msg, String... arguments) {
- System.out.println(transId + "|" + className + " : " + "MessageCode:" + msg + Arrays.asList(arguments));
+ displayMessage(transId + "|" + className + " : " + "MessageCode:" + msg + Arrays.asList(arguments));
}
/**
* Records a message.
- *
+ *
* @param message the message
*/
@Override
public void info(Object message) {
- System.out.println(transId + "|" + className + " : " + message);
+ displayMessage(transId + "|" + className + " : " + message);
}
/**
* Records a message.
- *
+ *
* @param message the message
* @param throwable the throwable
*/
@Override
public void info(Object message, Throwable throwable) {
- System.out.println(transId + "|" + className + " : " + message + ":" + throwable);
+ displayMessage(transId + "|" + className + " : " + message + ":" + throwable);
}
/**
* Records a message.
- *
+ *
* @param message the message
*/
@Override
public void warn(Object message) {
- System.out.println(transId + "|" + className + " : " + message);
+ displayMessage(transId + "|" + className + " : " + message);
}
/**
* Records a message.
- *
+ *
* @param message the message
* @param throwable the throwable
*/
@Override
public void warn(Object message, Throwable throwable) {
- System.out.println(transId + "|" + className + " : " + message + ":" + throwable);
+ displayMessage(transId + "|" + className + " : " + message + ":" + throwable);
}
/**
* Records a message.
- *
+ *
* @param msg the message code
* @param arguments the messages
*/
@Override
public void warn(MessageCodes msg, String... arguments) {
- System.out.println(transId + "|" + className + " : " + "MessageCodes:" + msg + Arrays.asList(arguments));
+ displayMessage(transId + "|" + className + " : " + "MessageCodes:" + msg + Arrays.asList(arguments));
}
/**
* Records a message.
- *
+ *
* @param msg the message code
* @param throwable the throwable
* @param arguments the messages
@@ -259,34 +261,34 @@ public class SystemOutLogger implements Logger, Serializable {
@Override
public void warn(MessageCodes msg, Throwable throwable, String... arguments) {
- System.out.println(transId + "|" + className + " : " + "MessageCodes:" + msg + Arrays.asList(arguments));
+ displayMessage(transId + "|" + className + " : " + "MessageCodes:" + msg + Arrays.asList(arguments));
}
/**
* Records a message.
- *
+ *
* @param message the message
*/
@Override
public void trace(Object message) {
- System.out.println(transId + "|" + className + " : " + message);
+ displayMessage(transId + "|" + className + " : " + message);
}
/**
* Records a message.
- *
+ *
* @param message the message
* @param throwable the throwable
*/
@Override
public void trace(Object message, Throwable throwable) {
- System.out.println(transId + "|" + className + " : " + message + ":" + throwable);
+ displayMessage(transId + "|" + className + " : " + message + ":" + throwable);
}
/**
* Returns true for debug enabled, or false for not.
- *
+ *
* @return boolean
*/
@Override
@@ -296,7 +298,7 @@ public class SystemOutLogger implements Logger, Serializable {
/**
* Returns true for warn enabled, or false for not.
- *
+ *
* @return boolean
*/
@Override
@@ -306,7 +308,7 @@ public class SystemOutLogger implements Logger, Serializable {
/**
* Returns true for info enabled, or false for not.
- *
+ *
* @return boolean
*/
@Override
@@ -316,7 +318,7 @@ public class SystemOutLogger implements Logger, Serializable {
/**
* Returns true for error enabled, or false for not.
- *
+ *
* @return boolean
*/
@Override
@@ -326,7 +328,7 @@ public class SystemOutLogger implements Logger, Serializable {
/**
* Returns true for audit enabled, or false for not.
- *
+ *
* @return boolean
*/
@Override
@@ -337,7 +339,7 @@ public class SystemOutLogger implements Logger, Serializable {
/**
* Returns true for metrics enabled, or false for not.
- *
+ *
* @return boolean
*/
@Override
@@ -348,52 +350,52 @@ public class SystemOutLogger implements Logger, Serializable {
/**
* Records an audit message.
- *
+ *
* @param message the message
*/
@Override
public void audit(Object message) {
- System.out.println(transId + "|" + className + " : " + message);
+ displayMessage(transId + "|" + className + " : " + message);
}
/**
* Records an audit message.
- *
+ *
* @param message the message
* @param throwable the throwable
*/
@Override
public void audit(Object message, Throwable throwable) {
- System.out.println(transId + "|" + className + " : " + message + ":" + throwable);
+ displayMessage(transId + "|" + className + " : " + message + ":" + throwable);
}
/**
* Records an audit message.
- *
+ *
* @param eventId the event ID
*/
@Override
public void recordAuditEventStart(String eventId) {
- System.out.println(transId + "|" + className + " : " + eventId);
+ displayMessage(transId + "|" + className + " : " + eventId);
}
/**
* Records an audit message.
- *
+ *
* @param eventId the event ID
*/
@Override
public void recordAuditEventStart(UUID eventId) {
- System.out.println(eventId);
+ displayMessage(eventId);
}
/**
* Records an audit message.
- *
+ *
* @param eventId the event ID
* @param rule the rule
* @param policyVersion the policy version
@@ -401,12 +403,12 @@ public class SystemOutLogger implements Logger, Serializable {
@Override
public void recordAuditEventEnd(String eventId, String rule, String policyVersion) {
- System.out.println(className + " : " + eventId + ":" + rule + ":" + policyVersion);
+ displayMessage(className + " : " + eventId + ":" + rule + ":" + policyVersion);
}
/**
* Records an audit message.
- *
+ *
* @param eventId the event ID
* @param rule the rule
* @param policyVersion the policy version
@@ -414,76 +416,76 @@ public class SystemOutLogger implements Logger, Serializable {
@Override
public void recordAuditEventEnd(UUID eventId, String rule, String policyVersion) {
- System.out.println(className + " : " + eventId + ":" + rule + ":" + policyVersion);
+ displayMessage(className + " : " + eventId + ":" + rule + ":" + policyVersion);
}
/**
* Records an audit message.
- *
+ *
* @param eventId the event ID
* @param rule the rule
*/
@Override
public void recordAuditEventEnd(String eventId, String rule) {
- System.out.println(className + " : " + eventId + ":" + rule);
+ displayMessage(className + " : " + eventId + ":" + rule);
}
/**
* Records an audit message.
- *
+ *
* @param eventId the event ID
* @param rule the rule
*/
@Override
public void recordAuditEventEnd(UUID eventId, String rule) {
- System.out.println(className + " : " + eventId + ":" + rule);
+ displayMessage(className + " : " + eventId + ":" + rule);
}
/**
* Records a metrics message.
- *
+ *
* @param eventId the event ID
* @param message the message
*/
@Override
public void recordMetricEvent(String eventId, String message) {
- System.out.println(className + " : " + "eventId:" + eventId + "message:" + message);
+ displayMessage(className + " : " + "eventId:" + eventId + "message:" + message);
}
/**
* Records a metrics message.
- *
+ *
* @param eventId the event ID
* @param message the message
*/
@Override
public void recordMetricEvent(UUID eventId, String message) {
- System.out.println(className + " : " + eventId + ":" + message);
+ displayMessage(className + " : " + eventId + ":" + message);
}
/**
* Records a metrics message.
- *
+ *
* @param message the message
*/
@Override
public void metrics(Object message) {
- System.out.println(className + " : " + message);
+ displayMessage(className + " : " + message);
}
/**
* Returns transaction Id.
- *
+ *
* @param transId the transaction ID
*/
@Override
- public String postMDCInfoForEvent(String transId) {
+ public String postMdcInfoForEvent(String transId) {
String transactionId = transId;
if (transactionId == null || transactionId.isEmpty()) {
@@ -495,18 +497,18 @@ public class SystemOutLogger implements Logger, Serializable {
/**
* Records transaction Id.
- *
+ *
* @param message the message
*/
@Override
- public void postMDCInfoForEvent(Object message) {
- System.out.println(message);
+ public void postMdcInfoForEvent(Object message) {
+ displayMessage(message);
}
/**
* Returns true for trace enabled, or false for not.
- *
+ *
* @return boolean
*/
@Override
@@ -517,13 +519,12 @@ public class SystemOutLogger implements Logger, Serializable {
/**
* Records transaction Id.
- *
+ *
* @param transId the transaction ID
*/
@Override
- public void postMDCInfoForTriggeredRule(String transId) {
+ public void postMdcInfoForTriggeredRule(String transId) {
- System.out.println(transId);
+ displayMessage(transId);
}
-
}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/nsa/LoggingContextFactory.java b/common-logging/src/main/java/org/onap/policy/common/logging/nsa/LoggingContextFactory.java
index 85600671..ee64306f 100644
--- a/common-logging/src/main/java/org/onap/policy/common/logging/nsa/LoggingContextFactory.java
+++ b/common-logging/src/main/java/org/onap/policy/common/logging/nsa/LoggingContextFactory.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP-Logging
* ================================================================================
- * 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.
@@ -25,7 +25,7 @@ import org.onap.policy.common.logging.nsa.impl.Slf4jLoggingContext;
/**
* A factory for setting up a LoggingContext.
- *
+ *
*/
public class LoggingContextFactory {
public static class Builder {
@@ -47,4 +47,8 @@ public class LoggingContextFactory {
return forShared ? new SharedContext(baseContext) : new Slf4jLoggingContext(baseContext);
}
}
+
+ private LoggingContextFactory() {
+ // do nothing
+ }
}
diff --git a/common-logging/src/test/java/org/onap/policy/common/logging/eelf/DroolsPDPMDCInfoTest.java b/common-logging/src/test/java/org/onap/policy/common/logging/eelf/DroolsPdpMdcInfoTest.java
index 3dd62e69..96030962 100644
--- a/common-logging/src/test/java/org/onap/policy/common/logging/eelf/DroolsPDPMDCInfoTest.java
+++ b/common-logging/src/test/java/org/onap/policy/common/logging/eelf/DroolsPdpMdcInfoTest.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP Policy Engine - Common Modules
* ================================================================================
- * 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.
@@ -23,19 +23,20 @@ package org.onap.policy.common.logging.eelf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import com.att.eelf.configuration.Configuration;
import org.junit.Test;
-public class DroolsPDPMDCInfoTest {
+public class DroolsPdpMdcInfoTest {
/**
- * Test method for {@link org.onap.policy.common.logging.eelf.DroolsPDPMDCInfo#getMDCInfo()}.
+ * Test method for {@link org.onap.policy.common.logging.eelf.DroolsPdpMdcInfo#getMdcInfo()}.
*/
@Test
- public void testGetMDCInfo() {
- DroolsPDPMDCInfo di = new DroolsPDPMDCInfo();
+ public void testGetMdcInfo() {
+ DroolsPdpMdcInfo di = new DroolsPdpMdcInfo();
- assertNotNull(di.getMDCInfo());
- assertEquals("Policy.droolsPdp", di.getMDCInfo().get(Configuration.MDC_SERVICE_NAME));
+ assertNotNull(di.getMdcInfo());
+ assertEquals("Policy.droolsPdp", di.getMdcInfo().get(Configuration.MDC_SERVICE_NAME));
}
}
diff --git a/common-logging/src/test/java/org/onap/policy/common/logging/eelf/EventDataTest.java b/common-logging/src/test/java/org/onap/policy/common/logging/eelf/EventDataTest.java
index f7aa733a..6fe81d27 100644
--- a/common-logging/src/test/java/org/onap/policy/common/logging/eelf/EventDataTest.java
+++ b/common-logging/src/test/java/org/onap/policy/common/logging/eelf/EventDataTest.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP Policy Engine - Common Modules
* ================================================================================
- * 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.
@@ -42,7 +42,7 @@ public class EventDataTest {
EventData eventData = new EventData();
assertNull(eventData.getEndTime());
- assertNull(eventData.getRequestID());
+ assertNull(eventData.getRequestId());
assertNull(eventData.getStartTime());
}
@@ -53,24 +53,24 @@ public class EventDataTest {
public void testEventDataStringInstantInstant() {
EventData eventData = new EventData("myreq", istart, iend);
- assertEquals("myreq", eventData.getRequestID());
+ assertEquals("myreq", eventData.getRequestId());
assertEquals(istart, eventData.getStartTime());
assertEquals(iend, eventData.getEndTime());
}
/**
- * Test method for {@link EventData#getRequestID()} and {@link EventData#setRequestID(String)}.
+ * Test method for {@link EventData#getRequestId()} and {@link EventData#setRequestId(String)}.
*/
@Test
public void testGetSetRequestId() {
EventData eventData = new EventData();
- assertNull(eventData.getRequestID());
+ assertNull(eventData.getRequestId());
- eventData.setRequestID("abc");
- assertEquals("abc", eventData.getRequestID());
+ eventData.setRequestId("abc");
+ assertEquals("abc", eventData.getRequestId());
- eventData.setRequestID("def");
- assertEquals("def", eventData.getRequestID());
+ eventData.setRequestId("def");
+ assertEquals("def", eventData.getRequestId());
}
/**
diff --git a/common-logging/src/test/java/org/onap/policy/common/logging/eelf/EventTrackInfoTest.java b/common-logging/src/test/java/org/onap/policy/common/logging/eelf/EventTrackInfoTest.java
index 7dc8fddc..e6024682 100644
--- a/common-logging/src/test/java/org/onap/policy/common/logging/eelf/EventTrackInfoTest.java
+++ b/common-logging/src/test/java/org/onap/policy/common/logging/eelf/EventTrackInfoTest.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP Policy Engine - Common Modules
* ================================================================================
- * 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.
@@ -55,16 +55,16 @@ public class EventTrackInfoTest {
}
/**
- * Test method for {@link EventTrackInfo#getEventDataByRequestID(String)}.
+ * Test method for {@link EventTrackInfo#getEventDataByRequestId(String)}.
*/
@Test
- public void testGetEventDataByRequestID() {
+ public void testGetEventDataByRequestId() {
info.storeEventData(data1);
info.storeEventData(data2);
- assertTrue(data1 == info.getEventDataByRequestID("abc"));
- assertTrue(data2 == info.getEventDataByRequestID("def"));
- assertNull(info.getEventDataByRequestID("hello"));
+ assertTrue(data1 == info.getEventDataByRequestId("abc"));
+ assertTrue(data2 == info.getEventDataByRequestId("def"));
+ assertNull(info.getEventDataByRequestId("hello"));
}
/**
@@ -86,14 +86,14 @@ public class EventTrackInfoTest {
assertEquals(2, info.getEventInfo().size());
// look-up by request id
- assertTrue(data1 == info.getEventDataByRequestID("abc"));
- assertTrue(data2 == info.getEventDataByRequestID("def"));
+ assertTrue(data1 == info.getEventDataByRequestId("abc"));
+ assertTrue(data2 == info.getEventDataByRequestId("def"));
// doesn't replace existing value
info.storeEventData(new EventData("abc", iend, istart));
assertEquals(2, info.getEventInfo().size());
- assertTrue(data1 == info.getEventDataByRequestID("abc"));
- assertTrue(data2 == info.getEventDataByRequestID("def"));
+ assertTrue(data1 == info.getEventDataByRequestId("abc"));
+ assertTrue(data2 == info.getEventDataByRequestId("def"));
}
/**
@@ -110,8 +110,8 @@ public class EventTrackInfoTest {
assertEquals(1, info.getEventInfo().size());
// look-up by request id
- assertNull(info.getEventDataByRequestID("abc"));
- assertTrue(data2 == info.getEventDataByRequestID("def"));
+ assertNull(info.getEventDataByRequestId("abc"));
+ assertTrue(data2 == info.getEventDataByRequestId("def"));
}
/**
diff --git a/common-logging/src/test/java/org/onap/policy/common/logging/eelf/PolicyLoggerTest.java b/common-logging/src/test/java/org/onap/policy/common/logging/eelf/PolicyLoggerTest.java
index 8d6b6d68..6af3632a 100644
--- a/common-logging/src/test/java/org/onap/policy/common/logging/eelf/PolicyLoggerTest.java
+++ b/common-logging/src/test/java/org/onap/policy/common/logging/eelf/PolicyLoggerTest.java
@@ -3,13 +3,14 @@
* ONAP-Logging
* ================================================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 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.
@@ -34,12 +35,11 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-import static org.onap.policy.common.logging.eelf.Configuration.PARTNER_NAME;
-import static org.onap.policy.common.logging.eelf.Configuration.RESPONSE_CODE;
-import static org.onap.policy.common.logging.eelf.Configuration.RESPONSE_DESCRIPTION;
-import static org.onap.policy.common.logging.eelf.Configuration.SERVER_NAME;
-import static org.onap.policy.common.logging.eelf.Configuration.STATUS_CODE;
-import static org.onap.policy.common.logging.util.TestUtils.overrideStaticField;
+import static org.onap.policy.common.logging.eelf.OnapConfigProperties.PARTNER_NAME;
+import static org.onap.policy.common.logging.eelf.OnapConfigProperties.RESPONSE_CODE;
+import static org.onap.policy.common.logging.eelf.OnapConfigProperties.RESPONSE_DESCRIPTION;
+import static org.onap.policy.common.logging.eelf.OnapConfigProperties.SERVER_NAME;
+import static org.onap.policy.common.logging.eelf.OnapConfigProperties.STATUS_CODE;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFLogger.Level;
@@ -51,6 +51,7 @@ import java.util.UUID;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
+import org.powermock.reflect.Whitebox;
import org.slf4j.MDC;
public class PolicyLoggerTest {
@@ -105,8 +106,8 @@ public class PolicyLoggerTest {
}
@Test
- public void testPostMDCInfoForEventString() {
- PolicyLogger.postMDCInfoForEvent("transactionId");
+ public void testPostMdcInfoForEventString() {
+ PolicyLogger.postMdcInfoForEvent("transactionId");
assertEquals("", MDC.get(MDC_REMOTE_HOST));
assertEquals("transactionId", MDC.get(MDC_KEY_REQUEST_ID));
@@ -121,12 +122,12 @@ public class PolicyLoggerTest {
}
@Test
- public void testPostMDCInfoForEventStringDrools() {
+ public void testPostMdcInfoForEventStringDrools() {
Properties properties = new Properties();
properties.setProperty("policy.component", "DROOLS");
PolicyLogger.init(properties);
- PolicyLogger.postMDCInfoForEvent("transactionId");
+ PolicyLogger.postMdcInfoForEvent("transactionId");
assertEquals("transactionId", MDC.get(MDC_KEY_REQUEST_ID));
assertEquals("Policy.droolsPdp", MDC.get(MDC_SERVICE_NAME));
@@ -140,8 +141,8 @@ public class PolicyLoggerTest {
}
@Test
- public void testPostMDCInfoForEventObject() {
- PolicyLogger.postMDCInfoForEvent(1);
+ public void testPostMdcInfoForEventObject() {
+ PolicyLogger.postMdcInfoForEvent(1);
assertEquals("", MDC.get(MDC_REMOTE_HOST));
assertEquals("1", MDC.get(MDC_KEY_REQUEST_ID));
@@ -156,8 +157,8 @@ public class PolicyLoggerTest {
}
@Test
- public void testPostMDCInfoForTriggeredRule() {
- PolicyLogger.postMDCInfoForTriggeredRule("transactionId");
+ public void testPostMdcInfoForTriggeredRule() {
+ PolicyLogger.postMdcInfoForTriggeredRule("transactionId");
assertEquals("", MDC.get(MDC_REMOTE_HOST));
assertEquals("transactionId", MDC.get(MDC_KEY_REQUEST_ID));
@@ -171,8 +172,8 @@ public class PolicyLoggerTest {
}
@Test
- public void testPostMDCUUIDForTriggeredRule() {
- PolicyLogger.postMDCUUIDForTriggeredRule(1);
+ public void testPostMdcUuidForTriggeredRule() {
+ PolicyLogger.postMdcUuidForTriggeredRule(1);
assertEquals("", MDC.get(MDC_REMOTE_HOST));
assertEquals("1", MDC.get(MDC_KEY_REQUEST_ID));
@@ -188,7 +189,7 @@ public class PolicyLoggerTest {
@Test
public void testInfoMessageCodesStringStringArray() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "debugLogger", mockLogger);
PolicyLogger.info(MessageCodes.ERROR_DATA_ISSUE, "str1", "str2");
Mockito.verify(mockLogger).info(MessageCodes.ERROR_DATA_ISSUE, "str2");
}
@@ -196,7 +197,7 @@ public class PolicyLoggerTest {
@Test
public void testInfoStringString() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "debugLogger", mockLogger);
PolicyLogger.info("str1", "str2");
Mockito.verify(mockLogger).info(MessageCodes.GENERAL_INFO, "str2");
}
@@ -204,7 +205,7 @@ public class PolicyLoggerTest {
@Test
public void testInfoObject() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "debugLogger", mockLogger);
PolicyLogger.info("str1");
Mockito.verify(mockLogger).info(MessageCodes.GENERAL_INFO, "str1");
}
@@ -212,7 +213,7 @@ public class PolicyLoggerTest {
@Test
public void testInfoMessageCodesThrowableStringArray() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "debugLogger", mockLogger);
PolicyLogger.info(MessageCodes.ERROR_DATA_ISSUE, new NullPointerException(), "str1", "str2");
Mockito.verify(mockLogger).info((MessageCodes) Mockito.any(),
Mockito.startsWith("str1:str2:java.lang.NullPointerException"));
@@ -221,7 +222,7 @@ public class PolicyLoggerTest {
@Test
public void testInfoMessageCodesStringThrowableStringArray() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "debugLogger", mockLogger);
PolicyLogger.info(MessageCodes.ERROR_DATA_ISSUE, "PolicyLoggerTest", new NullPointerException(), "str1",
"str2");
Mockito.verify(mockLogger).info((MessageCodes) Mockito.any(),
@@ -231,7 +232,7 @@ public class PolicyLoggerTest {
@Test
public void testWarnMessageCodesStringStringArray() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "debugLogger", mockLogger);
PolicyLogger.warn(MessageCodes.ERROR_DATA_ISSUE, "str1");
Mockito.verify(mockLogger).warn(MessageCodes.ERROR_DATA_ISSUE);
}
@@ -239,7 +240,7 @@ public class PolicyLoggerTest {
@Test
public void testWarnStringString() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "debugLogger", mockLogger);
PolicyLogger.warn("str1", "str2");
Mockito.verify(mockLogger).warn(MessageCodes.GENERAL_INFO, "str2");
}
@@ -247,7 +248,7 @@ public class PolicyLoggerTest {
@Test
public void testWarnObject() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "debugLogger", mockLogger);
PolicyLogger.warn(1);
Mockito.verify(mockLogger).warn(MessageCodes.GENERAL_WARNING, "1");
}
@@ -255,7 +256,7 @@ public class PolicyLoggerTest {
@Test
public void testWarnMessageCodesThrowableStringArray() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "debugLogger", mockLogger);
PolicyLogger.warn(MessageCodes.ERROR_DATA_ISSUE, new NullPointerException(), "str1", "str2");
Mockito.verify(mockLogger).warn((MessageCodes) Mockito.any(),
Mockito.startsWith("str1:str2:java.lang.NullPointerException"));
@@ -264,7 +265,7 @@ public class PolicyLoggerTest {
@Test
public void testWarnMessageCodesStringThrowableStringArray() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "debugLogger", mockLogger);
PolicyLogger.warn(MessageCodes.ERROR_DATA_ISSUE, "PolicyLoggerTest", new NullPointerException(), "str1",
"str2");
Mockito.verify(mockLogger).warn((MessageCodes) Mockito.any(),
@@ -274,7 +275,7 @@ public class PolicyLoggerTest {
@Test
public void testWarnString() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "debugLogger", mockLogger);
PolicyLogger.warn("str1");
Mockito.verify(mockLogger).warn(MessageCodes.GENERAL_WARNING, "str1");
}
@@ -282,7 +283,7 @@ public class PolicyLoggerTest {
@Test
public void testErrorStringString() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "errorLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "errorLogger", mockLogger);
PolicyLogger.error("str1", "str2");
Mockito.verify(mockLogger).error(MessageCodes.GENERAL_ERROR, "str2");
assertEquals("POLICY-515E", MDC.get("ErrorCode"));
@@ -293,7 +294,7 @@ public class PolicyLoggerTest {
@Test
public void testErrorString() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "errorLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "errorLogger", mockLogger);
PolicyLogger.error("str1");
Mockito.verify(mockLogger).error(MessageCodes.GENERAL_ERROR, "str1");
assertEquals("ERROR", MDC.get("ErrorCategory"));
@@ -305,7 +306,7 @@ public class PolicyLoggerTest {
@Test
public void testErrorObject() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "errorLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "errorLogger", mockLogger);
PolicyLogger.error(1);
Mockito.verify(mockLogger).error(MessageCodes.GENERAL_ERROR, "1");
assertEquals("ERROR", MDC.get("ErrorCategory"));
@@ -317,7 +318,7 @@ public class PolicyLoggerTest {
@Test
public void testErrorMessageCodesThrowableStringArray() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "errorLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "errorLogger", mockLogger);
PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, new NullPointerException(), "str1", "str2");
Mockito.verify(mockLogger).error((MessageCodes) Mockito.any(),
Mockito.startsWith("str1:str2:java.lang.NullPointerException"));
@@ -326,7 +327,7 @@ public class PolicyLoggerTest {
@Test
public void testErrorMessageCodesStringThrowableStringArray() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "errorLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "errorLogger", mockLogger);
PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, "PolicyLoggerTest", new NullPointerException(), "str1",
"str2");
Mockito.verify(mockLogger).error((MessageCodes) Mockito.any(),
@@ -336,7 +337,7 @@ public class PolicyLoggerTest {
@Test
public void testErrorMessageCodesStringArray() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "errorLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "errorLogger", mockLogger);
PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, "str1", "str2");
Mockito.verify(mockLogger).error(MessageCodes.ERROR_DATA_ISSUE, "str1", "str2");
}
@@ -344,7 +345,7 @@ public class PolicyLoggerTest {
@Test
public void testDebugMessageCodesStringArray() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "debugLogger", mockLogger);
PolicyLogger.debug(MessageCodes.ERROR_DATA_ISSUE, "str1", "str2");
Mockito.verify(mockLogger).debug(MessageCodes.ERROR_DATA_ISSUE, "str1", "str2");
}
@@ -352,7 +353,7 @@ public class PolicyLoggerTest {
@Test
public void testDebugStringString() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "debugLogger", mockLogger);
PolicyLogger.debug("str1", "str2");
Mockito.verify(mockLogger).debug(MessageCodes.GENERAL_INFO, "str2");
}
@@ -360,7 +361,7 @@ public class PolicyLoggerTest {
@Test
public void testDebugString() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "debugLogger", mockLogger);
PolicyLogger.debug("str1");
Mockito.verify(mockLogger).debug("str1");
}
@@ -368,7 +369,7 @@ public class PolicyLoggerTest {
@Test
public void testDebugObject() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "debugLogger", mockLogger);
PolicyLogger.debug(1);
Mockito.verify(mockLogger).debug("1");
}
@@ -376,7 +377,7 @@ public class PolicyLoggerTest {
@Test
public void testAuditStringObject() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "auditLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "auditLogger", mockLogger);
PolicyLogger.audit("PolicyLoggerTest", 1);
assertEquals("PolicyLoggerTest", MDC.get("ClassName"));
assertEquals("COMPLETE", MDC.get("StatusCode"));
@@ -386,7 +387,7 @@ public class PolicyLoggerTest {
@Test
public void testAuditObject() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "auditLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "auditLogger", mockLogger);
PolicyLogger.audit(1);
assertEquals("", MDC.get("ClassName"));
assertEquals("COMPLETE", MDC.get("StatusCode"));
@@ -396,7 +397,7 @@ public class PolicyLoggerTest {
@Test
public void testDebugMessageCodesThrowableStringArray() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "debugLogger", mockLogger);
PolicyLogger.debug(MessageCodes.ERROR_DATA_ISSUE, new NullPointerException(), "str1", "str2");
Mockito.verify(mockLogger).debug((MessageCodes) Mockito.any(),
Mockito.startsWith("str1:str2:java.lang.NullPointerException"));
@@ -405,7 +406,7 @@ public class PolicyLoggerTest {
@Test
public void testDebugMessageCodesStringThrowableStringArray() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "debugLogger", mockLogger);
PolicyLogger.debug(MessageCodes.ERROR_DATA_ISSUE, "PolicyLoggerTest", new NullPointerException(), "str1",
"str2");
Mockito.verify(mockLogger).debug((MessageCodes) Mockito.any(),
@@ -415,7 +416,7 @@ public class PolicyLoggerTest {
@Test
public void testIsDebugEnabled() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "debugLogger", mockLogger);
Mockito.when(mockLogger.isDebugEnabled()).thenReturn(false).thenReturn(true);
assertFalse(PolicyLogger.isDebugEnabled());
assertTrue(PolicyLogger.isDebugEnabled());
@@ -424,7 +425,7 @@ public class PolicyLoggerTest {
@Test
public void testIsErrorEnabled() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "errorLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "errorLogger", mockLogger);
Mockito.when(mockLogger.isErrorEnabled()).thenReturn(false).thenReturn(true);
assertFalse(PolicyLogger.isErrorEnabled());
assertTrue(PolicyLogger.isErrorEnabled());
@@ -433,7 +434,7 @@ public class PolicyLoggerTest {
@Test
public void testIsWarnEnabled() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "debugLogger", mockLogger);
Mockito.when(mockLogger.isWarnEnabled()).thenReturn(false).thenReturn(true);
assertFalse(PolicyLogger.isWarnEnabled());
assertTrue(PolicyLogger.isWarnEnabled());
@@ -442,7 +443,7 @@ public class PolicyLoggerTest {
@Test
public void testIsInfoEnabled1() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "debugLogger", mockLogger);
Mockito.when(mockLogger.isInfoEnabled()).thenReturn(false).thenReturn(true);
assertFalse(PolicyLogger.isInfoEnabled1());
assertTrue(PolicyLogger.isInfoEnabled1());
@@ -451,7 +452,7 @@ public class PolicyLoggerTest {
@Test
public void testIsAuditEnabled() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "debugLogger", mockLogger);
Mockito.when(mockLogger.isInfoEnabled()).thenReturn(false).thenReturn(true);
assertFalse(PolicyLogger.isAuditEnabled());
assertTrue(PolicyLogger.isAuditEnabled());
@@ -460,7 +461,7 @@ public class PolicyLoggerTest {
@Test
public void testIsInfoEnabled() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "debugLogger", mockLogger);
Mockito.when(mockLogger.isInfoEnabled()).thenReturn(false).thenReturn(true);
assertFalse(PolicyLogger.isInfoEnabled());
assertTrue(PolicyLogger.isInfoEnabled());
@@ -469,7 +470,7 @@ public class PolicyLoggerTest {
@Test
public void testTraceStringString() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "debugLogger", mockLogger);
PolicyLogger.trace("str1", "str2");
Mockito.verify(mockLogger).trace(MessageCodes.GENERAL_INFO, "str2");
}
@@ -477,7 +478,7 @@ public class PolicyLoggerTest {
@Test
public void testTraceObject() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "debugLogger", mockLogger);
PolicyLogger.trace(1);
Mockito.verify(mockLogger).trace("1");
}
@@ -492,7 +493,7 @@ public class PolicyLoggerTest {
}
@Test
- public void testRecordAuditEventStartAndEndUUID() {
+ public void testRecordAuditEventStartAndEndUuid() {
UUID uuid = UUID.randomUUID();
PolicyLogger.recordAuditEventStart(uuid);;
assertNotNull(PolicyLogger.getEventTracker().getEventInfo().get(uuid.toString()));
@@ -512,7 +513,7 @@ public class PolicyLoggerTest {
}
@Test
- public void testRecordAuditEventEndUUIDStringString() {
+ public void testRecordAuditEventEndUuidStringString() {
UUID uuid = UUID.randomUUID();
PolicyLogger.recordAuditEventStart(uuid);;
assertNotNull(PolicyLogger.getEventTracker().getEventInfo().get(uuid.toString()));
@@ -532,7 +533,7 @@ public class PolicyLoggerTest {
}
@Test
- public void testCreatAuditEventTrackingRecordUUIDString() {
+ public void testCreatAuditEventTrackingRecordUuidString() {
UUID uuid = UUID.randomUUID();
PolicyLogger.recordAuditEventStart(uuid);;
assertNotNull(PolicyLogger.getEventTracker().getEventInfo().get(uuid.toString()));
@@ -560,7 +561,7 @@ public class PolicyLoggerTest {
}
@Test
- public void testRecordMetricEventUUIDString() {
+ public void testRecordMetricEventUuidString() {
UUID uuid = UUID.randomUUID();
PolicyLogger.recordMetricEvent(uuid, "str1");
assertEquals(uuid.toString(), MDC.get(MDC_KEY_REQUEST_ID));
@@ -569,7 +570,7 @@ public class PolicyLoggerTest {
@Test
public void testRecordMetricEventString() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "metricsLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "metricsLogger", mockLogger);
PolicyLogger.recordMetricEvent("eventId");
Mockito.verify(mockLogger).info(Mockito.eq(MessageCodes.RULE_METRICS_INFO), Mockito.anyString(),
Mockito.eq("eventId"));
@@ -578,7 +579,7 @@ public class PolicyLoggerTest {
@Test
public void testMetricsString() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "metricsLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "metricsLogger", mockLogger);
PolicyLogger.metrics("str1");
Mockito.verify(mockLogger).info(Mockito.eq(MessageCodes.RULE_METRICS_INFO), Mockito.anyString(),
Mockito.eq("str1"));
@@ -587,7 +588,7 @@ public class PolicyLoggerTest {
@Test
public void testMetricsStringObject() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "metricsLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "metricsLogger", mockLogger);
PolicyLogger.metrics("PolicyLoggerTest", 1);
Mockito.verify(mockLogger).info(Mockito.eq(MessageCodes.RULE_METRICS_INFO), Mockito.anyString(),
Mockito.eq("1"));
@@ -596,7 +597,7 @@ public class PolicyLoggerTest {
@Test
public void testMetricsObject() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "metricsLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "metricsLogger", mockLogger);
PolicyLogger.metrics(1);
Mockito.verify(mockLogger).info(Mockito.eq(MessageCodes.RULE_METRICS_INFO), Mockito.anyString(),
Mockito.eq("1"));
@@ -605,7 +606,7 @@ public class PolicyLoggerTest {
@Test
public void testMetricsPrintln() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "metricsLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "metricsLogger", mockLogger);
PolicyLogger.metricsPrintln("str1");
Mockito.verify(mockLogger).info("str1");
}
diff --git a/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/EelfLoggerTest.java b/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/EelfLoggerTest.java
index a7e835ce..d3c09ee6 100644
--- a/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/EelfLoggerTest.java
+++ b/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/EelfLoggerTest.java
@@ -3,13 +3,14 @@
* ONAP-Logging
* ================================================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 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.
@@ -26,16 +27,14 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-import static org.onap.policy.common.logging.util.TestUtils.overrideStaticField;
import com.att.eelf.configuration.EELFLogger;
-
import java.util.UUID;
-
import org.junit.Test;
import org.mockito.Mockito;
import org.onap.policy.common.logging.eelf.MessageCodes;
import org.onap.policy.common.logging.eelf.PolicyLogger;
+import org.powermock.reflect.Whitebox;
import org.slf4j.MDC;
public class EelfLoggerTest {
@@ -92,7 +91,7 @@ public class EelfLoggerTest {
@Test
public void testDebugObject() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "debugLogger", mockLogger);
eelfLogger.debug("message");
Mockito.verify(mockLogger).debug(MessageCodes.GENERAL_INFO, "message");
}
@@ -100,7 +99,7 @@ public class EelfLoggerTest {
@Test
public void testErrorObject() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "errorLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "errorLogger", mockLogger);
eelfLogger.error("message");
Mockito.verify(mockLogger).error(MessageCodes.GENERAL_ERROR, "message");
}
@@ -108,7 +107,7 @@ public class EelfLoggerTest {
@Test
public void testInfoObject() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "debugLogger", mockLogger);
eelfLogger.info("message");
Mockito.verify(mockLogger).info(MessageCodes.GENERAL_INFO, "message");
}
@@ -116,7 +115,7 @@ public class EelfLoggerTest {
@Test
public void testWarnObject() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "debugLogger", mockLogger);
eelfLogger.warn("message");
Mockito.verify(mockLogger).warn(MessageCodes.GENERAL_INFO, "message");
}
@@ -124,7 +123,7 @@ public class EelfLoggerTest {
@Test
public void testTraceObject() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "debugLogger", mockLogger);
eelfLogger.trace("message");
Mockito.verify(mockLogger).trace(MessageCodes.GENERAL_INFO, "message");
}
@@ -132,7 +131,7 @@ public class EelfLoggerTest {
@Test
public void testIsDebugEnabled() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "debugLogger", mockLogger);
Mockito.when(mockLogger.isDebugEnabled()).thenReturn(false).thenReturn(true);
assertFalse(eelfLogger.isDebugEnabled());
assertTrue(eelfLogger.isDebugEnabled());
@@ -142,7 +141,7 @@ public class EelfLoggerTest {
@Test
public void testIsInfoEnabled() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "debugLogger", mockLogger);
Mockito.when(mockLogger.isInfoEnabled()).thenReturn(false).thenReturn(true);
assertFalse(eelfLogger.isInfoEnabled());
assertTrue(eelfLogger.isInfoEnabled());
@@ -151,7 +150,7 @@ public class EelfLoggerTest {
@Test
public void testIsWarnEnabled() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "debugLogger", mockLogger);
Mockito.when(mockLogger.isWarnEnabled()).thenReturn(false).thenReturn(true);
assertFalse(eelfLogger.isWarnEnabled());
assertTrue(eelfLogger.isWarnEnabled());
@@ -160,7 +159,7 @@ public class EelfLoggerTest {
@Test
public void testIsErrorEnabled() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "errorLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "errorLogger", mockLogger);
Mockito.when(mockLogger.isErrorEnabled()).thenReturn(false).thenReturn(true);
assertFalse(eelfLogger.isErrorEnabled());
assertTrue(eelfLogger.isErrorEnabled());
@@ -183,7 +182,7 @@ public class EelfLoggerTest {
@Test
public void testIsTraceEnabled() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "debugLogger", mockLogger);
Mockito.when(mockLogger.isDebugEnabled()).thenReturn(false).thenReturn(true);
assertFalse(eelfLogger.isTraceEnabled());
assertTrue(eelfLogger.isTraceEnabled());
@@ -199,7 +198,7 @@ public class EelfLoggerTest {
@Test
public void testDebugObjectThrowable() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "debugLogger", mockLogger);
eelfLogger.debug("message", new NullPointerException());
Mockito.verify(mockLogger).debug((MessageCodes) Mockito.any(),
Mockito.startsWith("message:java.lang.NullPointerException"));
@@ -208,7 +207,7 @@ public class EelfLoggerTest {
@Test
public void testErrorObjectThrowable() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "errorLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "errorLogger", mockLogger);
eelfLogger.error("message", new NullPointerException());
Mockito.verify(mockLogger).error((MessageCodes) Mockito.any(),
Mockito.startsWith("message:java.lang.NullPointerException"));
@@ -218,7 +217,7 @@ public class EelfLoggerTest {
@Test
public void testInfoObjectThrowable() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "debugLogger", mockLogger);
eelfLogger.info("message", new NullPointerException());
Mockito.verify(mockLogger).info((MessageCodes) Mockito.any(),
Mockito.startsWith("message:java.lang.NullPointerException"));
@@ -227,7 +226,7 @@ public class EelfLoggerTest {
@Test
public void testWarnObjectThrowable() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "debugLogger", mockLogger);
eelfLogger.warn("message", new NullPointerException());
Mockito.verify(mockLogger).warn((MessageCodes) Mockito.any(),
Mockito.startsWith("message:java.lang.NullPointerException"));
@@ -236,7 +235,7 @@ public class EelfLoggerTest {
@Test
public void testTraceObjectThrowable() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "debugLogger", mockLogger);
eelfLogger.trace("message", new NullPointerException());
Mockito.verify(mockLogger).trace("message");
}
@@ -244,7 +243,7 @@ public class EelfLoggerTest {
@Test
public void testAuditObjectThrowable() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "auditLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "auditLogger", mockLogger);
eelfLogger.audit("message", new NullPointerException());
Mockito.verify(mockLogger).info("message");
}
@@ -256,7 +255,7 @@ public class EelfLoggerTest {
}
@Test
- public void testRecordAuditEventStartUUID() {
+ public void testRecordAuditEventStartUuid() {
UUID uuid = UUID.randomUUID();
eelfLogger.recordAuditEventStart(uuid);
assertNotNull(PolicyLogger.getEventTracker().getEventInfo().get(uuid.toString()));
@@ -272,7 +271,7 @@ public class EelfLoggerTest {
}
@Test
- public void testRecordAuditEventEndUUIDStringString() {
+ public void testRecordAuditEventEndUuidStringString() {
UUID uuid = UUID.randomUUID();
eelfLogger.recordAuditEventStart(uuid);;
assertNotNull(PolicyLogger.getEventTracker().getEventInfo().get(uuid.toString()));
@@ -291,7 +290,7 @@ public class EelfLoggerTest {
}
@Test
- public void testRecordAuditEventEndUUIDString() {
+ public void testRecordAuditEventEndUuidString() {
UUID uuid = UUID.randomUUID();
eelfLogger.recordAuditEventStart(uuid);;
assertNotNull(PolicyLogger.getEventTracker().getEventInfo().get(uuid.toString()));
@@ -307,7 +306,7 @@ public class EelfLoggerTest {
}
@Test
- public void testRecordMetricEventUUIDString() {
+ public void testRecordMetricEventUuidString() {
UUID uuid = UUID.randomUUID();
eelfLogger.recordMetricEvent(uuid, "str2");
assertEquals(uuid.toString(), MDC.get(MDC_KEY_REQUEST_ID));
@@ -316,7 +315,7 @@ public class EelfLoggerTest {
@Test
public void testMetrics() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "metricsLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "metricsLogger", mockLogger);
eelfLogger.metrics(1);
Mockito.verify(mockLogger).info(Mockito.eq(MessageCodes.RULE_METRICS_INFO), Mockito.anyString(),
Mockito.eq("1"));
@@ -325,7 +324,7 @@ public class EelfLoggerTest {
@Test
public void testErrorMessageCodesThrowableStringArray() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "errorLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "errorLogger", mockLogger);
eelfLogger.error(MessageCodes.GENERAL_ERROR, new NullPointerException(), "str1", "str2");
Mockito.verify(mockLogger).error((MessageCodes) Mockito.any(),
Mockito.startsWith("str1:str2:java.lang.NullPointerException"));
@@ -334,22 +333,22 @@ public class EelfLoggerTest {
@Test
public void testErrorMessageCodesStringArray() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "errorLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "errorLogger", mockLogger);
eelfLogger.error(MessageCodes.GENERAL_ERROR, "str1", "str2");
Mockito.verify(mockLogger).error(MessageCodes.GENERAL_ERROR, "str1", "str2");
}
@Test
- public void testPostMDCInfoForEventString() {
- eelfLogger.postMDCInfoForEvent("transactionId");
+ public void testPostMdcInfoForEventString() {
+ eelfLogger.postMdcInfoForEvent("transactionId");
assertEquals("transactionId", MDC.get(MDC_KEY_REQUEST_ID));
}
@Test
public void testWarnMessageCodesStringArray() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "debugLogger", mockLogger);
eelfLogger.warn(MessageCodes.GENERAL_ERROR, "str1", "str2");
Mockito.verify(mockLogger).warn(MessageCodes.GENERAL_ERROR, "str1", "str2");
}
@@ -357,7 +356,7 @@ public class EelfLoggerTest {
@Test
public void testWarnMessageCodesThrowableStringArray() {
EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger);
+ Whitebox.setInternalState(PolicyLogger.class, "debugLogger", mockLogger);
eelfLogger.warn(MessageCodes.GENERAL_ERROR, new NullPointerException(), "str1", "str2");
Mockito.verify(mockLogger).warn((MessageCodes) Mockito.any(),
Mockito.startsWith("str1:str2:java.lang.NullPointerException"));
@@ -365,14 +364,14 @@ public class EelfLoggerTest {
}
@Test
- public void testPostMDCInfoForTriggeredRule() {
- eelfLogger.postMDCInfoForTriggeredRule("transactionId");
+ public void testPostMdcInfoForTriggeredRule() {
+ eelfLogger.postMdcInfoForTriggeredRule("transactionId");
assertEquals("transactionId", MDC.get(MDC_KEY_REQUEST_ID));
}
@Test
- public void testPostMDCInfoForEventObject() {
- eelfLogger.postMDCInfoForEvent(1);
+ public void testPostMDdcInfoForEventObject() {
+ eelfLogger.postMdcInfoForEvent(1);
assertEquals("1", MDC.get(MDC_KEY_REQUEST_ID));
}
diff --git a/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/FlexLoggerTest.java b/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/FlexLoggerTest.java
index 7d6088eb..a74dd94d 100644
--- a/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/FlexLoggerTest.java
+++ b/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/FlexLoggerTest.java
@@ -3,13 +3,14 @@
* ONAP-Logging
* ================================================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 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,20 +23,19 @@ package org.onap.policy.common.logging.flexlogger;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertSame;
-import static org.onap.policy.common.logging.util.TestUtils.overrideStaticField;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
-
import org.junit.Test;
import org.onap.policy.common.logging.flexlogger.FlexLogger.PropertiesCallBack;
+import org.powermock.reflect.Whitebox;
public class FlexLoggerTest {
@Test
public void testGetLoggerClassOfQEelf() {
- overrideStaticField(FlexLogger.class, "loggerType", LoggerType.EELF);
+ Whitebox.setInternalState(FlexLogger.class, "loggerType", LoggerType.EELF);
Logger logger = FlexLogger.getLogger((Class<?>) null);
assertSame(logger, FlexLogger.getLogger((Class<?>) null));
assertNotEquals(logger, FlexLogger.getLogger(String.class));
@@ -43,77 +43,77 @@ public class FlexLoggerTest {
@Test
public void testGetLoggerClassOfQLog4j() {
- overrideStaticField(FlexLogger.class, "loggerType", LoggerType.LOG4J);
+ Whitebox.setInternalState(FlexLogger.class, "loggerType", LoggerType.LOG4J);
Logger logger = FlexLogger.getLogger(this.getClass());
assertSame(logger, FlexLogger.getLogger(this.getClass()));
}
@Test
public void testGetLoggerClassOfQSystemOut() {
- overrideStaticField(FlexLogger.class, "loggerType", LoggerType.SYSTEMOUT);
+ Whitebox.setInternalState(FlexLogger.class, "loggerType", LoggerType.SYSTEMOUT);
Logger logger = FlexLogger.getLogger(this.getClass());
assertSame(logger, FlexLogger.getLogger(this.getClass()));
}
@Test
public void testGetLoggerStringEelf() {
- overrideStaticField(FlexLogger.class, "loggerType", LoggerType.EELF);
+ Whitebox.setInternalState(FlexLogger.class, "loggerType", LoggerType.EELF);
Logger logger = FlexLogger.getLogger("str1");
assertSame(logger, FlexLogger.getLogger("str1"));
}
@Test
public void testGetLoggerStringLog4j() {
- overrideStaticField(FlexLogger.class, "loggerType", LoggerType.LOG4J);
+ Whitebox.setInternalState(FlexLogger.class, "loggerType", LoggerType.LOG4J);
Logger logger = FlexLogger.getLogger("str1");
assertSame(logger, FlexLogger.getLogger("str1"));
}
@Test
public void testGetLoggerStringSystemOut() {
- overrideStaticField(FlexLogger.class, "loggerType", LoggerType.SYSTEMOUT);
+ Whitebox.setInternalState(FlexLogger.class, "loggerType", LoggerType.SYSTEMOUT);
Logger logger = FlexLogger.getLogger("str1");
assertSame(logger, FlexLogger.getLogger("str1"));
}
@Test
public void testGetLoggerClassOfQBooleanEelf() {
- overrideStaticField(FlexLogger.class, "loggerType", LoggerType.EELF);
+ Whitebox.setInternalState(FlexLogger.class, "loggerType", LoggerType.EELF);
Logger logger = FlexLogger.getLogger(this.getClass(), true);
assertSame(logger, FlexLogger.getLogger(this.getClass(), true));
}
@Test
public void testGetLoggerClassOfQBooleanLog4j() {
- overrideStaticField(FlexLogger.class, "loggerType", LoggerType.LOG4J);
+ Whitebox.setInternalState(FlexLogger.class, "loggerType", LoggerType.LOG4J);
Logger logger = FlexLogger.getLogger(this.getClass(), true);
assertSame(logger, FlexLogger.getLogger(this.getClass(), true));
}
@Test
public void testGetLoggerClassOfQBooleanSystemOut() {
- overrideStaticField(FlexLogger.class, "loggerType", LoggerType.SYSTEMOUT);
+ Whitebox.setInternalState(FlexLogger.class, "loggerType", LoggerType.SYSTEMOUT);
Logger logger = FlexLogger.getLogger(this.getClass(), true);
assertSame(logger, FlexLogger.getLogger(this.getClass(), true));
}
@Test
public void testGetLoggerStringBooleanEelf() {
- overrideStaticField(FlexLogger.class, "loggerType", LoggerType.EELF);
+ Whitebox.setInternalState(FlexLogger.class, "loggerType", LoggerType.EELF);
Logger logger = FlexLogger.getLogger("str1", true);
assertSame(logger, FlexLogger.getLogger("str1", true));
}
@Test
public void testGetLoggerStringBooleanLog4j() {
- overrideStaticField(FlexLogger.class, "loggerType", LoggerType.LOG4J);
+ Whitebox.setInternalState(FlexLogger.class, "loggerType", LoggerType.LOG4J);
Logger logger = FlexLogger.getLogger("str1", true);
assertSame(logger, FlexLogger.getLogger("str1", true));
}
@Test
public void testGetLoggerStringBooleanSystemOut() {
- overrideStaticField(FlexLogger.class, "loggerType", LoggerType.SYSTEMOUT);
+ Whitebox.setInternalState(FlexLogger.class, "loggerType", LoggerType.SYSTEMOUT);
Logger logger = FlexLogger.getLogger("str1", true);
assertSame(logger, FlexLogger.getLogger("str1", true));
}
diff --git a/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/Logger4JTest.java b/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/Logger4JTest.java
index 7f2964c2..99c343c0 100644
--- a/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/Logger4JTest.java
+++ b/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/Logger4JTest.java
@@ -3,13 +3,14 @@
* ONAP-Logging
* ================================================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 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.
@@ -27,13 +28,12 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.UUID;
-
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.junit.Test;
import org.mockito.Mockito;
import org.onap.policy.common.logging.eelf.MessageCodes;
-import org.onap.policy.common.logging.util.TestUtils;
+import org.powermock.reflect.Whitebox;
public class Logger4JTest {
@@ -53,7 +53,7 @@ public class Logger4JTest {
@Test
public void testDebugObject() {
Logger logger = Mockito.mock(Logger.class);
- TestUtils.overrideField(Logger4J.class, logger4J, "log", logger);
+ Whitebox.setInternalState(logger4J, "log", logger);
Mockito.when(logger.isDebugEnabled()).thenReturn(true);
logger4J.setTransId("transactionId");
logger4J.debug("message");
@@ -63,7 +63,7 @@ public class Logger4JTest {
@Test
public void testErrorObject() {
Logger logger = Mockito.mock(Logger.class);
- TestUtils.overrideField(Logger4J.class, logger4J, "log", logger);
+ Whitebox.setInternalState(logger4J, "log", logger);
logger4J.setTransId("transactionId");
logger4J.error("message");
Mockito.verify(logger).error("transactionId|Logger4JTest|message");
@@ -72,7 +72,7 @@ public class Logger4JTest {
@Test
public void testInfoObject() {
Logger logger = Mockito.mock(Logger.class);
- TestUtils.overrideField(Logger4J.class, logger4J, "log", logger);
+ Whitebox.setInternalState(logger4J, "log", logger);
logger4J.setTransId("transactionId");
logger4J.info("message");
Mockito.verify(logger).info("transactionId|Logger4JTest|message");
@@ -81,7 +81,7 @@ public class Logger4JTest {
@Test
public void testWarnObject() {
Logger logger = Mockito.mock(Logger.class);
- TestUtils.overrideField(Logger4J.class, logger4J, "log", logger);
+ Whitebox.setInternalState(logger4J, "log", logger);
logger4J.setTransId("transactionId");
logger4J.warn("message");
Mockito.verify(logger).warn("transactionId|Logger4JTest|message");
@@ -90,7 +90,7 @@ public class Logger4JTest {
@Test
public void testTraceObject() {
Logger logger = Mockito.mock(Logger.class);
- TestUtils.overrideField(Logger4J.class, logger4J, "log", logger);
+ Whitebox.setInternalState(logger4J, "log", logger);
logger4J.setTransId("transactionId");
logger4J.trace("message");
Mockito.verify(logger).trace("transactionId|Logger4JTest|message");
@@ -99,7 +99,7 @@ public class Logger4JTest {
@Test
public void testIsDebugEnabled() {
Logger logger = Mockito.mock(Logger.class);
- TestUtils.overrideField(Logger4J.class, logger4J, "log", logger);
+ Whitebox.setInternalState(logger4J, "log", logger);
Mockito.when(logger.isDebugEnabled()).thenReturn(true).thenReturn(false);
assertTrue(logger4J.isDebugEnabled());
assertFalse(logger4J.isDebugEnabled());
@@ -108,7 +108,7 @@ public class Logger4JTest {
@Test
public void testIsErrorEnabled() {
Logger logger = Mockito.mock(Logger.class);
- TestUtils.overrideField(Logger4J.class, logger4J, "log", logger);
+ Whitebox.setInternalState(logger4J, "log", logger);
Mockito.when(logger.isEnabledFor(Level.ERROR)).thenReturn(true).thenReturn(false);
assertTrue(logger4J.isErrorEnabled());
assertFalse(logger4J.isErrorEnabled());
@@ -117,7 +117,7 @@ public class Logger4JTest {
@Test
public void testIsInfoEnabled() {
Logger logger = Mockito.mock(Logger.class);
- TestUtils.overrideField(Logger4J.class, logger4J, "log", logger);
+ Whitebox.setInternalState(logger4J, "log", logger);
Mockito.when(logger.isInfoEnabled()).thenReturn(true).thenReturn(false);
assertTrue(logger4J.isInfoEnabled());
assertFalse(logger4J.isInfoEnabled());
@@ -126,7 +126,7 @@ public class Logger4JTest {
@Test
public void testIsWarnEnabled() {
Logger logger = Mockito.mock(Logger.class);
- TestUtils.overrideField(Logger4J.class, logger4J, "log", logger);
+ Whitebox.setInternalState(logger4J, "log", logger);
Mockito.when(logger.isEnabledFor(Level.WARN)).thenReturn(true).thenReturn(false);
assertTrue(logger4J.isWarnEnabled());
assertFalse(logger4J.isWarnEnabled());
@@ -135,7 +135,7 @@ public class Logger4JTest {
@Test
public void testAuditObject() {
Logger logger = Mockito.mock(Logger.class);
- TestUtils.overrideField(Logger4J.class, logger4J, "log", logger);
+ Whitebox.setInternalState(logger4J, "log", logger);
logger4J.audit("str1");
Mockito.verify(logger).info("Logger4JTest|str1");
}
@@ -143,15 +143,15 @@ public class Logger4JTest {
@Test
public void testRecordAuditEventStartString() {
Logger logger = Mockito.mock(Logger.class);
- TestUtils.overrideField(Logger4J.class, logger4J, "log", logger);
+ Whitebox.setInternalState(logger4J, "log", logger);
logger4J.recordAuditEventEnd("eventId", "rule");
Mockito.verify(logger).info("Logger4JTest|eventId:rule");
}
@Test
- public void testRecordAuditEventStartUUID() {
+ public void testRecordAuditEventStartUuid() {
Logger logger = Mockito.mock(Logger.class);
- TestUtils.overrideField(Logger4J.class, logger4J, "log", logger);
+ Whitebox.setInternalState(logger4J, "log", logger);
UUID uuid = UUID.randomUUID();
logger4J.recordAuditEventStart(uuid);
Mockito.verify(logger).info("Logger4JTest|recordAuditEventStart with eventId " + uuid.toString());
@@ -160,15 +160,15 @@ public class Logger4JTest {
@Test
public void testRecordAuditEventEndStringStringString() {
Logger logger = Mockito.mock(Logger.class);
- TestUtils.overrideField(Logger4J.class, logger4J, "log", logger);
+ Whitebox.setInternalState(logger4J, "log", logger);
logger4J.recordAuditEventEnd("eventId", "rule", "policyVersion");
Mockito.verify(logger).info("Logger4JTest|eventId:rule");
}
@Test
- public void testRecordAuditEventEndUUIDStringString() {
+ public void testRecordAuditEventEndUuidStringString() {
Logger logger = Mockito.mock(Logger.class);
- TestUtils.overrideField(Logger4J.class, logger4J, "log", logger);
+ Whitebox.setInternalState(logger4J, "log", logger);
UUID uuid = UUID.randomUUID();
logger4J.recordAuditEventEnd(uuid, "rule", "policyVersion");
Mockito.verify(logger).info("Logger4JTest|" + uuid.toString() + ":rule");
@@ -177,15 +177,15 @@ public class Logger4JTest {
@Test
public void testRecordAuditEventEndStringString() {
Logger logger = Mockito.mock(Logger.class);
- TestUtils.overrideField(Logger4J.class, logger4J, "log", logger);
+ Whitebox.setInternalState(logger4J, "log", logger);
logger4J.recordAuditEventEnd("eventId", "rule");
Mockito.verify(logger).info("Logger4JTest|eventId:rule");
}
@Test
- public void testRecordAuditEventEndUUIDString() {
+ public void testRecordAuditEventEndUuidString() {
Logger logger = Mockito.mock(Logger.class);
- TestUtils.overrideField(Logger4J.class, logger4J, "log", logger);
+ Whitebox.setInternalState(logger4J, "log", logger);
UUID uuid = UUID.randomUUID();
logger4J.recordAuditEventEnd(uuid, "rule");
Mockito.verify(logger).info("Logger4JTest|" + uuid.toString() + ":rule");
@@ -194,15 +194,15 @@ public class Logger4JTest {
@Test
public void testRecordMetricEventStringString() {
Logger logger = Mockito.mock(Logger.class);
- TestUtils.overrideField(Logger4J.class, logger4J, "log", logger);
+ Whitebox.setInternalState(logger4J, "log", logger);
logger4J.recordMetricEvent("eventId", "str1");
Mockito.verify(logger).info("Logger4JTest|eventId:str1");
}
@Test
- public void testRecordMetricEventUUIDString() {
+ public void testRecordMetricEventUuidString() {
Logger logger = Mockito.mock(Logger.class);
- TestUtils.overrideField(Logger4J.class, logger4J, "log", logger);
+ Whitebox.setInternalState(logger4J, "log", logger);
UUID uuid = UUID.randomUUID();
logger4J.recordMetricEvent(uuid, "str1");
Mockito.verify(logger).info("Logger4JTest|" + uuid.toString() + ":str1");
@@ -211,7 +211,7 @@ public class Logger4JTest {
@Test
public void testMetrics() {
Logger logger = Mockito.mock(Logger.class);
- TestUtils.overrideField(Logger4J.class, logger4J, "log", logger);
+ Whitebox.setInternalState(logger4J, "log", logger);
logger4J.metrics("str1");
Mockito.verify(logger).info("str1");
}
@@ -219,7 +219,7 @@ public class Logger4JTest {
@Test
public void testErrorMessageCodesThrowableStringArray() {
Logger logger = Mockito.mock(Logger.class);
- TestUtils.overrideField(Logger4J.class, logger4J, "log", logger);
+ Whitebox.setInternalState(logger4J, "log", logger);
logger4J.setTransId("transactionId");
logger4J.error(MessageCodes.GENERAL_ERROR, new NullPointerException(), "str1", "str2");
Mockito.verify(logger)
@@ -229,7 +229,7 @@ public class Logger4JTest {
@Test
public void testErrorMessageCodesStringArray() {
Logger logger = Mockito.mock(Logger.class);
- TestUtils.overrideField(Logger4J.class, logger4J, "log", logger);
+ Whitebox.setInternalState(logger4J, "log", logger);
logger4J.setTransId("transactionId");
logger4J.error(MessageCodes.GENERAL_ERROR, "str1", "str2");
Mockito.verify(logger)
@@ -237,14 +237,14 @@ public class Logger4JTest {
}
@Test
- public void testPostMDCInfoForEventString() {
- String returnedTransactionId = logger4J.postMDCInfoForEvent("transactionId");
+ public void testPostMdcInfoForEventString() {
+ String returnedTransactionId = logger4J.postMdcInfoForEvent("transactionId");
assertEquals("transactionId", returnedTransactionId);
}
@Test
- public void testPostMDCInfoForEventEmptyString() {
- String returnedTransactionId = logger4J.postMDCInfoForEvent("");
+ public void testPostMdcInfoForEventEmptyString() {
+ String returnedTransactionId = logger4J.postMdcInfoForEvent("");
assertNotNull("", returnedTransactionId);
assertNotEquals("", returnedTransactionId);
}
@@ -252,7 +252,7 @@ public class Logger4JTest {
@Test
public void testWarnMessageCodesStringArray() {
Logger logger = Mockito.mock(Logger.class);
- TestUtils.overrideField(Logger4J.class, logger4J, "log", logger);
+ Whitebox.setInternalState(logger4J, "log", logger);
logger4J.warn(MessageCodes.GENERAL_ERROR, "str1", "str2");
Mockito.verify(logger).warn("Logger4JTest|MessageCodes:" + MessageCodes.GENERAL_ERROR + "[str1, str2]");
}
@@ -260,7 +260,7 @@ public class Logger4JTest {
@Test
public void testWarnMessageCodesThrowableStringArray() {
Logger logger = Mockito.mock(Logger.class);
- TestUtils.overrideField(Logger4J.class, logger4J, "log", logger);
+ Whitebox.setInternalState(logger4J, "log", logger);
logger4J.setTransId("transactionId");
logger4J.warn(MessageCodes.GENERAL_ERROR, new NullPointerException(), "str1", "str2");
Mockito.verify(logger).warn("Logger4JTest|MessageCodes:" + MessageCodes.GENERAL_ERROR + "[str1, str2]");
@@ -269,7 +269,7 @@ public class Logger4JTest {
@Test
public void testDebugObjectThrowable() {
Logger logger = Mockito.mock(Logger.class);
- TestUtils.overrideField(Logger4J.class, logger4J, "log", logger);
+ Whitebox.setInternalState(logger4J, "log", logger);
logger4J.setTransId("transactionId");
Exception exception = new NullPointerException();
logger4J.debug("message", exception);
@@ -279,7 +279,7 @@ public class Logger4JTest {
@Test
public void testErrorObjectThrowable() {
Logger logger = Mockito.mock(Logger.class);
- TestUtils.overrideField(Logger4J.class, logger4J, "log", logger);
+ Whitebox.setInternalState(logger4J, "log", logger);
logger4J.setTransId("transactionId");
Exception exception = new NullPointerException();
logger4J.error("message", exception);
@@ -289,7 +289,7 @@ public class Logger4JTest {
@Test
public void testInfoObjectThrowable() {
Logger logger = Mockito.mock(Logger.class);
- TestUtils.overrideField(Logger4J.class, logger4J, "log", logger);
+ Whitebox.setInternalState(logger4J, "log", logger);
logger4J.setTransId("transactionId");
Exception exception = new NullPointerException();
logger4J.info("message", exception);
@@ -299,7 +299,7 @@ public class Logger4JTest {
@Test
public void testWarnObjectThrowable() {
Logger logger = Mockito.mock(Logger.class);
- TestUtils.overrideField(Logger4J.class, logger4J, "log", logger);
+ Whitebox.setInternalState(logger4J, "log", logger);
Exception exception = new NullPointerException();
logger4J.warn("message", exception);
Mockito.verify(logger).warn("message", exception);
@@ -308,7 +308,7 @@ public class Logger4JTest {
@Test
public void testTraceObjectThrowable() {
Logger logger = Mockito.mock(Logger.class);
- TestUtils.overrideField(Logger4J.class, logger4J, "log", logger);
+ Whitebox.setInternalState(logger4J, "log", logger);
Exception exception = new NullPointerException();
logger4J.trace("message", exception);
Mockito.verify(logger).trace("message", exception);
@@ -317,7 +317,7 @@ public class Logger4JTest {
@Test
public void testAuditObjectThrowable() {
Logger logger = Mockito.mock(Logger.class);
- TestUtils.overrideField(Logger4J.class, logger4J, "log", logger);
+ Whitebox.setInternalState(logger4J, "log", logger);
Exception exception = new NullPointerException();
logger4J.audit("message", exception);
Mockito.verify(logger).info("message", exception);
@@ -326,24 +326,24 @@ public class Logger4JTest {
@Test
public void testIsTraceEnabled() {
Logger logger = Mockito.mock(Logger.class);
- TestUtils.overrideField(Logger4J.class, logger4J, "log", logger);
+ Whitebox.setInternalState(logger4J, "log", logger);
logger4J.isTraceEnabled();
Mockito.verify(logger).isTraceEnabled();
}
@Test
- public void testPostMDCInfoForTriggeredRule() {
+ public void testPostMdcInfoForTriggeredRule() {
Logger logger = Mockito.mock(Logger.class);
- TestUtils.overrideField(Logger4J.class, logger4J, "log", logger);
- logger4J.postMDCInfoForTriggeredRule("transactionId");
+ Whitebox.setInternalState(logger4J, "log", logger);
+ logger4J.postMdcInfoForTriggeredRule("transactionId");
Mockito.verify(logger).info("transactionId");
}
@Test
- public void testPostMDCInfoForEventObject() {
+ public void testPostMdcInfoForEventObject() {
Logger logger = Mockito.mock(Logger.class);
- TestUtils.overrideField(Logger4J.class, logger4J, "log", logger);
- logger4J.postMDCInfoForEvent(1);
+ Whitebox.setInternalState(logger4J, "log", logger);
+ logger4J.postMdcInfoForEvent(1);
Mockito.verify(logger).info(1);
}
diff --git a/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/SystemOutLoggerTest.java b/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/SystemOutLoggerTest.java
index cd16a3fd..92df0297 100644
--- a/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/SystemOutLoggerTest.java
+++ b/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/SystemOutLoggerTest.java
@@ -3,13 +3,14 @@
* ONAP-Logging
* ================================================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 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.
@@ -222,7 +223,7 @@ public class SystemOutLoggerTest {
}
@Test
- public void testRecordAuditEventStartUUID() {
+ public void testRecordAuditEventStartUuid() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(baos);
PrintStream old = System.out;
@@ -253,7 +254,7 @@ public class SystemOutLoggerTest {
}
@Test
- public void testRecordAuditEventEndUUIDStringString() {
+ public void testRecordAuditEventEndUuidStringString() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(baos);
PrintStream old = System.out;
@@ -284,7 +285,7 @@ public class SystemOutLoggerTest {
}
@Test
- public void testRecordAuditEventEndUUIDString() {
+ public void testRecordAuditEventEndUuidString() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(baos);
PrintStream old = System.out;
@@ -315,7 +316,7 @@ public class SystemOutLoggerTest {
}
@Test
- public void testRecordMetricEventUUIDString() {
+ public void testRecordMetricEventUuidString() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(baos);
PrintStream old = System.out;
@@ -379,8 +380,8 @@ public class SystemOutLoggerTest {
}
@Test
- public void testPostMDCInfoForEventString() {
- assertEquals("transactionId", systemOutLogger.postMDCInfoForEvent("transactionId"));
+ public void testPostMdcInfoForEventString() {
+ assertEquals("transactionId", systemOutLogger.postMdcInfoForEvent("transactionId"));
}
@Test
@@ -525,13 +526,13 @@ public class SystemOutLoggerTest {
}
@Test
- public void testPostMDCInfoForTriggeredRule() {
+ public void testPostMdcInfoForTriggeredRule() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(baos);
PrintStream old = System.out;
try {
System.setOut(ps);
- systemOutLogger.postMDCInfoForTriggeredRule("transactionId");
+ systemOutLogger.postMdcInfoForTriggeredRule("transactionId");
assertTrue(baos.toString(), baos.toString().contains("transactionId"));
} finally {
System.out.flush();
@@ -540,13 +541,13 @@ public class SystemOutLoggerTest {
}
@Test
- public void testPostMDCInfoForEventObject() {
+ public void testPostMdcInfoForEventObject() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(baos);
PrintStream old = System.out;
try {
System.setOut(ps);
- systemOutLogger.postMDCInfoForEvent(1);
+ systemOutLogger.postMdcInfoForEvent(1);
assertTrue(baos.toString(), baos.toString().contains("1"));
} finally {
System.out.flush();
diff --git a/common-logging/src/test/java/org/onap/policy/common/logging/util/TestUtils.java b/common-logging/src/test/java/org/onap/policy/common/logging/util/TestUtils.java
deleted file mode 100644
index 94bfbb74..00000000
--- a/common-logging/src/test/java/org/onap/policy/common/logging/util/TestUtils.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP-Logging
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-
-
-package org.onap.policy.common.logging.util;
-
-import static org.junit.Assert.fail;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-
-public class TestUtils {
-
- /**
- * Override a field.
- *
- * @param clazz the class the field belongs to
- * @param object the instance of the class
- * @param fieldName the name of the field
- * @param newValue the value to set the field to
- */
- public static void overrideField(@SuppressWarnings("rawtypes") final Class clazz, final Object object,
- final String fieldName, final Object newValue) {
- try {
- final Field field = clazz.getDeclaredField(fieldName);
- field.setAccessible(true);
-
- final Field modifiersField = Field.class.getDeclaredField("modifiers");
- modifiersField.setAccessible(true);
-
- field.set(object, newValue);
- } catch (final Exception e) {
- fail(e.toString());
- }
- }
-
- /**
- * Override a static field.
- *
- * @param clazz the class the field belongs to
- * @param fieldName the name of the field
- * @param newValue the value to set the field to
- */
- public static void overrideStaticField(@SuppressWarnings("rawtypes") final Class clazz, final String fieldName,
- final Object newValue) {
- try {
- final Field field = clazz.getDeclaredField(fieldName);
- field.setAccessible(true);
-
- final Field modifiersField = Field.class.getDeclaredField("modifiers");
- modifiersField.setAccessible(true);
- modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
-
- field.set(null, newValue);
- } catch (final Exception e) {
- fail(e.toString());
- }
- }
-
-}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpoint.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpoint.java
index ff8b9513..7bc7abab 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpoint.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpoint.java
@@ -38,11 +38,6 @@ import org.onap.policy.common.endpoints.event.comm.bus.UebTopicSource;
public interface TopicEndpoint extends Startable, Lockable {
/**
- * singleton for global access.
- */
- TopicEndpoint manager = new TopicEndpointProxy();
-
- /**
* Add topics configuration (sources and sinks) into a single list.
*
* @param properties topic configuration
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointManager.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointManager.java
new file mode 100644
index 00000000..c390afc6
--- /dev/null
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointManager.java
@@ -0,0 +1,37 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.endpoints.event.comm;
+
+import lombok.Getter;
+
+public class TopicEndpointManager {
+
+ /**
+ * Topic endpoint manager.
+ */
+ @Getter
+ private static TopicEndpoint manager = new TopicEndpointProxy();
+
+
+ private TopicEndpointManager() {
+ // do nothing
+ }
+}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxy.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxy.java
index 806d077c..00980fc4 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxy.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxy.java
@@ -25,10 +25,13 @@ 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.event.comm.bus.DmaapTopicFactories;
import org.onap.policy.common.endpoints.event.comm.bus.DmaapTopicSink;
import org.onap.policy.common.endpoints.event.comm.bus.DmaapTopicSource;
+import org.onap.policy.common.endpoints.event.comm.bus.NoopTopicFactories;
import org.onap.policy.common.endpoints.event.comm.bus.NoopTopicSink;
import org.onap.policy.common.endpoints.event.comm.bus.NoopTopicSource;
+import org.onap.policy.common.endpoints.event.comm.bus.UebTopicFactories;
import org.onap.policy.common.endpoints.event.comm.bus.UebTopicSink;
import org.onap.policy.common.endpoints.event.comm.bus.UebTopicSource;
import org.onap.policy.common.gson.annotation.GsonJsonIgnore;
@@ -71,9 +74,9 @@ class TopicEndpointProxy implements TopicEndpoint {
List<TopicSource> sources = new ArrayList<>();
- sources.addAll(UebTopicSource.factory.build(properties));
- sources.addAll(DmaapTopicSource.factory.build(properties));
- sources.addAll(NoopTopicSource.factory.build(properties));
+ sources.addAll(UebTopicFactories.getSourceFactory().build(properties));
+ sources.addAll(DmaapTopicFactories.getSourceFactory().build(properties));
+ sources.addAll(NoopTopicFactories.getSourceFactory().build(properties));
if (this.isLocked()) {
for (final TopicSource source : sources) {
@@ -92,9 +95,9 @@ class TopicEndpointProxy implements TopicEndpoint {
final List<TopicSink> sinks = new ArrayList<>();
- sinks.addAll(UebTopicSink.factory.build(properties));
- sinks.addAll(DmaapTopicSink.factory.build(properties));
- sinks.addAll(NoopTopicSink.factory.build(properties));
+ sinks.addAll(UebTopicFactories.getSinkFactory().build(properties));
+ sinks.addAll(DmaapTopicFactories.getSinkFactory().build(properties));
+ sinks.addAll(NoopTopicFactories.getSinkFactory().build(properties));
if (this.isLocked()) {
for (final TopicSink sink : sinks) {
@@ -110,9 +113,9 @@ class TopicEndpointProxy implements TopicEndpoint {
final List<TopicSource> sources = new ArrayList<>();
- sources.addAll(UebTopicSource.factory.inventory());
- sources.addAll(DmaapTopicSource.factory.inventory());
- sources.addAll(NoopTopicSource.factory.inventory());
+ sources.addAll(UebTopicFactories.getSourceFactory().inventory());
+ sources.addAll(DmaapTopicFactories.getSourceFactory().inventory());
+ sources.addAll(NoopTopicFactories.getSourceFactory().inventory());
return sources;
}
@@ -161,9 +164,9 @@ class TopicEndpointProxy implements TopicEndpoint {
final List<TopicSink> sinks = new ArrayList<>();
- sinks.addAll(UebTopicSink.factory.inventory());
- sinks.addAll(DmaapTopicSink.factory.inventory());
- sinks.addAll(NoopTopicSink.factory.inventory());
+ sinks.addAll(UebTopicFactories.getSinkFactory().inventory());
+ sinks.addAll(DmaapTopicFactories.getSinkFactory().inventory());
+ sinks.addAll(NoopTopicFactories.getSinkFactory().inventory());
return sinks;
}
@@ -240,42 +243,42 @@ class TopicEndpointProxy implements TopicEndpoint {
@GsonJsonIgnore
@Override
public List<UebTopicSource> getUebTopicSources() {
- return UebTopicSource.factory.inventory();
+ return UebTopicFactories.getSourceFactory().inventory();
}
@JsonIgnore
@GsonJsonIgnore
@Override
public List<DmaapTopicSource> getDmaapTopicSources() {
- return DmaapTopicSource.factory.inventory();
+ return DmaapTopicFactories.getSourceFactory().inventory();
}
@JsonIgnore
@GsonJsonIgnore
@Override
public List<NoopTopicSource> getNoopTopicSources() {
- return NoopTopicSource.factory.inventory();
+ return NoopTopicFactories.getSourceFactory().inventory();
}
@JsonIgnore
@GsonJsonIgnore
@Override
public List<UebTopicSink> getUebTopicSinks() {
- return UebTopicSink.factory.inventory();
+ return UebTopicFactories.getSinkFactory().inventory();
}
@JsonIgnore
@GsonJsonIgnore
@Override
public List<DmaapTopicSink> getDmaapTopicSinks() {
- return DmaapTopicSink.factory.inventory();
+ return DmaapTopicFactories.getSinkFactory().inventory();
}
@JsonIgnore
@GsonJsonIgnore
@Override
public List<NoopTopicSink> getNoopTopicSinks() {
- return NoopTopicSink.factory.inventory();
+ return NoopTopicFactories.getSinkFactory().inventory();
}
@Override
@@ -354,14 +357,14 @@ class TopicEndpointProxy implements TopicEndpoint {
public void shutdown() {
this.stop();
- UebTopicSource.factory.destroy();
- UebTopicSink.factory.destroy();
+ UebTopicFactories.getSourceFactory().destroy();
+ UebTopicFactories.getSinkFactory().destroy();
- DmaapTopicSource.factory.destroy();
- DmaapTopicSink.factory.destroy();
+ DmaapTopicFactories.getSourceFactory().destroy();
+ DmaapTopicFactories.getSinkFactory().destroy();
- NoopTopicSink.factory.destroy();
- NoopTopicSource.factory.destroy();
+ NoopTopicFactories.getSinkFactory().destroy();
+ NoopTopicFactories.getSourceFactory().destroy();
}
@@ -465,32 +468,32 @@ class TopicEndpointProxy implements TopicEndpoint {
@Override
public UebTopicSource getUebTopicSource(String topicName) {
- return UebTopicSource.factory.get(topicName);
+ return UebTopicFactories.getSourceFactory().get(topicName);
}
@Override
public UebTopicSink getUebTopicSink(String topicName) {
- return UebTopicSink.factory.get(topicName);
+ return UebTopicFactories.getSinkFactory().get(topicName);
}
@Override
public DmaapTopicSource getDmaapTopicSource(String topicName) {
- return DmaapTopicSource.factory.get(topicName);
+ return DmaapTopicFactories.getSourceFactory().get(topicName);
}
@Override
public NoopTopicSource getNoopTopicSource(String topicName) {
- return NoopTopicSource.factory.get(topicName);
+ return NoopTopicFactories.getSourceFactory().get(topicName);
}
@Override
public DmaapTopicSink getDmaapTopicSink(String topicName) {
- return DmaapTopicSink.factory.get(topicName);
+ return DmaapTopicFactories.getSinkFactory().get(topicName);
}
@Override
public NoopTopicSink getNoopTopicSink(String topicName) {
- return NoopTopicSink.factory.get(topicName);
+ return NoopTopicFactories.getSinkFactory().get(topicName);
}
private IllegalArgumentException parmException(String topicName) {
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicSink.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicSink.java
index ed796585..e77beea1 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicSink.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicSink.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* policy-endpoints
* ================================================================================
- * 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.
@@ -26,21 +26,17 @@ import org.onap.policy.common.endpoints.event.comm.TopicSink;
* Topic Sink over Bus Infrastructure (DMAAP/UEB).
*/
public interface BusTopicSink extends ApiKeyEnabled, TopicSink {
- /**
- * Log Failures after X number of retries.
- */
- public static final int DEFAULT_LOG_SEND_FAILURES_AFTER = 1;
/**
* Sets the UEB partition key for published messages.
- *
+ *
* @param partitionKey the partition key
*/
public void setPartitionKey(String partitionKey);
/**
* Return the partition key in used by the system to publish messages.
- *
+ *
* @return the partition key
*/
public String getPartitionKey();
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicSource.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicSource.java
index 5ab4d46f..cd9bc015 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicSource.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicSource.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* policy-endpoints
* ================================================================================
- * 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.
@@ -29,49 +29,29 @@ import org.onap.policy.common.endpoints.event.comm.TopicSource;
public interface BusTopicSource extends ApiKeyEnabled, TopicSource {
/**
- * Default Timeout fetching in milliseconds.
- */
- public static int DEFAULT_TIMEOUT_MS_FETCH = 15000;
-
- /**
- * Default maximum number of messages fetch at the time.
- */
- public static int DEFAULT_LIMIT_FETCH = 100;
-
- /**
- * Definition of No Timeout fetching.
- */
- public static int NO_TIMEOUT_MS_FETCH = -1;
-
- /**
- * Definition of No limit fetching.
- */
- public static int NO_LIMIT_FETCH = -1;
-
- /**
* Gets the consumer group.
- *
+ *
* @return consumer group
*/
public String getConsumerGroup();
/**
* Gets the consumer instance.
- *
+ *
* @return consumer instance
*/
public String getConsumerInstance();
/**
* Gets the fetch timeout.
- *
+ *
* @return fetch timeout
*/
public int getFetchTimeout();
/**
* Gets the fetch limit.
- *
+ *
* @return fetch limit
*/
public int getFetchLimit();
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicFactories.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicFactories.java
new file mode 100644
index 00000000..d5a46f8f
--- /dev/null
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicFactories.java
@@ -0,0 +1,43 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.endpoints.event.comm.bus;
+
+import lombok.Getter;
+
+public class DmaapTopicFactories {
+
+ /**
+ * Factory for instantiation and management of sinks.
+ */
+ @Getter
+ private static final DmaapTopicSinkFactory sinkFactory = new IndexedDmaapTopicSinkFactory();
+
+ /**
+ * Factory for instantiation and management of sources.
+ */
+ @Getter
+ private static final DmaapTopicSourceFactory sourceFactory = new IndexedDmaapTopicSourceFactory();
+
+
+ private DmaapTopicFactories() {
+ // do nothing
+ }
+}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSink.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSink.java
index fc1587e4..805ed108 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSink.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSink.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* policy-endpoints
* ================================================================================
- * 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.
@@ -22,9 +22,4 @@ package org.onap.policy.common.endpoints.event.comm.bus;
public interface DmaapTopicSink extends BusTopicSink {
- /**
- * Factory of UebTopicWriter for instantiation and management purposes.
- */
-
- public static final DmaapTopicSinkFactory factory = new IndexedDmaapTopicSinkFactory();
}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkFactory.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkFactory.java
index a3eb4df6..4409e827 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkFactory.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkFactory.java
@@ -30,15 +30,6 @@ import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
*/
public interface DmaapTopicSinkFactory {
- String DME2_READ_TIMEOUT_PROPERTY = "AFT_DME2_EP_READ_TIMEOUT_MS";
- String DME2_EP_CONN_TIMEOUT_PROPERTY = "AFT_DME2_EP_CONN_TIMEOUT";
- String DME2_ROUNDTRIP_TIMEOUT_PROPERTY = "AFT_DME2_ROUNDTRIP_TIMEOUT_MS";
- String DME2_VERSION_PROPERTY = "Version";
- String DME2_ROUTE_OFFER_PROPERTY = "routeOffer";
- String DME2_SERVICE_NAME_PROPERTY = "ServiceName";
- String DME2_SUBCONTEXT_PATH_PROPERTY = "SubContextPath";
- String DME2_SESSION_STICKINESS_REQUIRED_PROPERTY = "sessionstickinessrequired";
-
/**
* <pre>
* Instantiate a new DMAAP Topic Sink, with following params.
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSource.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSource.java
index 2cf07bda..9893fa15 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSource.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSource.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* policy-endpoints
* ================================================================================
- * 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.
@@ -22,8 +22,4 @@ package org.onap.policy.common.endpoints.event.comm.bus;
public interface DmaapTopicSource extends BusTopicSource {
- /**
- * factory for managing and tracking DMAAP sources.
- */
- public static DmaapTopicSourceFactory factory = new IndexedDmaapTopicSourceFactory();
}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceFactory.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceFactory.java
index 35a79bf1..7b1f185b 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceFactory.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceFactory.java
@@ -8,9 +8,9 @@
* 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.
@@ -29,20 +29,12 @@ import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
* DMAAP Topic Source Factory.
*/
public interface DmaapTopicSourceFactory {
- String DME2_READ_TIMEOUT_PROPERTY = "AFT_DME2_EP_READ_TIMEOUT_MS";
- String DME2_EP_CONN_TIMEOUT_PROPERTY = "AFT_DME2_EP_CONN_TIMEOUT";
- String DME2_ROUNDTRIP_TIMEOUT_PROPERTY = "AFT_DME2_ROUNDTRIP_TIMEOUT_MS";
- String DME2_VERSION_PROPERTY = "Version";
- String DME2_ROUTE_OFFER_PROPERTY = "routeOffer";
- String DME2_SERVICE_NAME_PROPERTY = "ServiceName";
- String DME2_SUBCONTEXT_PATH_PROPERTY = "SubContextPath";
- String DME2_SESSION_STICKINESS_REQUIRED_PROPERTY = "sessionstickinessrequired";
/**
* Creates an DMAAP Topic Source based on properties files.
- *
+ *
* @param properties Properties containing initialization values
- *
+ *
* @return an DMAAP Topic Source
* @throws IllegalArgumentException if invalid parameters are present
*/
@@ -50,7 +42,7 @@ public interface DmaapTopicSourceFactory {
/**
* Instantiates a new DMAAP Topic Source.
- *
+ *
* @param busTopicParams parameters object
* @return a DMAAP Topic Source
*/
@@ -58,12 +50,12 @@ public interface DmaapTopicSourceFactory {
/**
* Instantiates a new DMAAP Topic Source.
- *
+ *
* @param servers list of servers
* @param topic topic name
* @param apiKey API Key
* @param apiSecret API Secret
- *
+ *
* @return an DMAAP Topic Source
* @throws IllegalArgumentException if invalid parameters are present
*/
@@ -71,10 +63,10 @@ public interface DmaapTopicSourceFactory {
/**
* Instantiates a new DMAAP Topic Source.
- *
+ *
* @param servers list of servers
* @param topic topic name
- *
+ *
* @return an DMAAP Topic Source
* @throws IllegalArgumentException if invalid parameters are present
*/
@@ -82,7 +74,7 @@ public interface DmaapTopicSourceFactory {
/**
* Destroys an DMAAP Topic Source based on a topic.
- *
+ *
* @param topic topic name
* @throws IllegalArgumentException if invalid parameters are present
*/
@@ -95,7 +87,7 @@ public interface DmaapTopicSourceFactory {
/**
* Gets an DMAAP Topic Source based on topic name.
- *
+ *
* @param topic the topic name
* @return an DMAAP Topic Source with topic name
* @throws IllegalArgumentException if an invalid topic is provided
@@ -105,7 +97,7 @@ public interface DmaapTopicSourceFactory {
/**
* Provides a snapshot of the DMAAP Topic Sources.
- *
+ *
* @return a list of the DMAAP Topic Sources
*/
List<DmaapTopicSource> inventory();
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedDmaapTopicSourceFactory.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedDmaapTopicSourceFactory.java
index c895a409..d7f4695e 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedDmaapTopicSourceFactory.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedDmaapTopicSourceFactory.java
@@ -96,8 +96,8 @@ class IndexedDmaapTopicSourceFactory implements DmaapTopicSourceFactory {
.topic(topic)
.apiKey(apiKey)
.apiSecret(apiSecret)
- .fetchTimeout(DmaapTopicSource.DEFAULT_TIMEOUT_MS_FETCH)
- .fetchLimit(DmaapTopicSource.DEFAULT_LIMIT_FETCH)
+ .fetchTimeout(PolicyEndPointProperties.DEFAULT_TIMEOUT_MS_FETCH)
+ .fetchLimit(PolicyEndPointProperties.DEFAULT_LIMIT_FETCH)
.managed(true)
.useHttps(false)
.allowSelfSignedCerts(false)
@@ -133,9 +133,9 @@ class IndexedDmaapTopicSourceFactory implements DmaapTopicSourceFactory {
PolicyEndPointProperties.PROPERTY_TOPIC_SOURCE_CONSUMER_INSTANCE_SUFFIX, null))
.fetchTimeout(props.getInteger(
PolicyEndPointProperties.PROPERTY_TOPIC_SOURCE_FETCH_TIMEOUT_SUFFIX,
- DmaapTopicSource.DEFAULT_TIMEOUT_MS_FETCH))
+ PolicyEndPointProperties.DEFAULT_TIMEOUT_MS_FETCH))
.fetchLimit(props.getInteger(PolicyEndPointProperties.PROPERTY_TOPIC_SOURCE_FETCH_LIMIT_SUFFIX,
- DmaapTopicSource.DEFAULT_LIMIT_FETCH))
+ PolicyEndPointProperties.DEFAULT_LIMIT_FETCH))
.build());
dmaapTopicSourceLst.add(uebTopicSource);
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedUebTopicSourceFactory.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedUebTopicSourceFactory.java
index 6655aa12..5bdc8ab6 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedUebTopicSourceFactory.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedUebTopicSourceFactory.java
@@ -100,8 +100,8 @@ class IndexedUebTopicSourceFactory implements UebTopicSourceFactory {
.topic(topic)
.apiKey(apiKey)
.apiSecret(apiSecret)
- .fetchTimeout(UebTopicSource.DEFAULT_TIMEOUT_MS_FETCH)
- .fetchLimit(UebTopicSource.DEFAULT_LIMIT_FETCH)
+ .fetchTimeout(PolicyEndPointProperties.DEFAULT_TIMEOUT_MS_FETCH)
+ .fetchLimit(PolicyEndPointProperties.DEFAULT_LIMIT_FETCH)
.managed(true)
.useHttps(false)
.allowSelfSignedCerts(true).build());
@@ -136,9 +136,9 @@ class IndexedUebTopicSourceFactory implements UebTopicSourceFactory {
PolicyEndPointProperties.PROPERTY_TOPIC_SOURCE_CONSUMER_INSTANCE_SUFFIX, null))
.fetchTimeout(props.getInteger(
PolicyEndPointProperties.PROPERTY_TOPIC_SOURCE_FETCH_TIMEOUT_SUFFIX,
- UebTopicSource.DEFAULT_TIMEOUT_MS_FETCH))
+ PolicyEndPointProperties.DEFAULT_TIMEOUT_MS_FETCH))
.fetchLimit(props.getInteger(PolicyEndPointProperties.PROPERTY_TOPIC_SOURCE_FETCH_LIMIT_SUFFIX,
- UebTopicSource.DEFAULT_LIMIT_FETCH))
+ PolicyEndPointProperties.DEFAULT_LIMIT_FETCH))
.build());
newUebTopicSources.add(uebTopicSource);
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicFactories.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicFactories.java
new file mode 100644
index 00000000..aa85e714
--- /dev/null
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicFactories.java
@@ -0,0 +1,43 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.endpoints.event.comm.bus;
+
+import lombok.Getter;
+
+public class NoopTopicFactories {
+
+ /**
+ * Factory for instantiation and management of sinks.
+ */
+ @Getter
+ private static final NoopTopicSinkFactory sinkFactory = new NoopTopicSinkFactory();
+
+ /**
+ * Factory for instantiation and management of sources.
+ */
+ @Getter
+ private static final NoopTopicSourceFactory sourceFactory = new NoopTopicSourceFactory();
+
+
+ private NoopTopicFactories() {
+ // do nothing
+ }
+}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSink.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSink.java
index c52a30be..e7accad5 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSink.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSink.java
@@ -30,11 +30,6 @@ import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
public class NoopTopicSink extends NoopTopicEndpoint implements TopicSink {
/**
- * Factory.
- */
- public static final NoopTopicSinkFactory factory = new NoopTopicSinkFactory();
-
- /**
* Constructs the object.
*/
public NoopTopicSink(List<String> servers, String topic) {
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSource.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSource.java
index a5b9349e..6f2c4a1e 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSource.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSource.java
@@ -30,11 +30,6 @@ import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
public class NoopTopicSource extends NoopTopicEndpoint implements TopicSource {
/**
- * Factory.
- */
- public static final NoopTopicSourceFactory factory = new NoopTopicSourceFactory();
-
- /**
* Constructs the object.
*/
public NoopTopicSource(List<String> servers, String topic) {
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicFactories.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicFactories.java
new file mode 100644
index 00000000..d02758be
--- /dev/null
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicFactories.java
@@ -0,0 +1,43 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.endpoints.event.comm.bus;
+
+import lombok.Getter;
+
+public class UebTopicFactories {
+
+ /**
+ * Factory for instantiation and management of sinks.
+ */
+ @Getter
+ private static final UebTopicSinkFactory sinkFactory = new IndexedUebTopicSinkFactory();
+
+ /**
+ * Factory for instantiation and management of sources.
+ */
+ @Getter
+ private static final UebTopicSourceFactory sourceFactory = new IndexedUebTopicSourceFactory();
+
+
+ private UebTopicFactories() {
+ // do nothing
+ }
+}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSink.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSink.java
index bc1251d5..acfef6da 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSink.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSink.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* policy-endpoints
* ================================================================================
- * 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.
@@ -25,8 +25,4 @@ package org.onap.policy.common.endpoints.event.comm.bus;
*/
public interface UebTopicSink extends BusTopicSink {
- /**
- * Factory of UEB Topic Sinks for instantiation and management purposes.
- */
- public static final UebTopicSinkFactory factory = new IndexedUebTopicSinkFactory();
}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSource.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSource.java
index ee4f013b..56534309 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSource.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSource.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* policy-endpoints
* ================================================================================
- * 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.
@@ -26,8 +26,4 @@ package org.onap.policy.common.endpoints.event.comm.bus;
*/
public interface UebTopicSource extends BusTopicSource {
- /**
- * factory for managing and tracking UEB readers.
- */
- public static UebTopicSourceFactory factory = new IndexedUebTopicSourceFactory();
}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumer.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumer.java
index abf793d6..b66b4ba5 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumer.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumer.java
@@ -24,7 +24,6 @@ package org.onap.policy.common.endpoints.event.comm.bus.internal;
import com.att.nsa.cambria.client.CambriaClientBuilders;
import com.att.nsa.cambria.client.CambriaClientBuilders.ConsumerBuilder;
import com.att.nsa.cambria.client.CambriaConsumer;
-
import java.io.IOException;
import java.net.MalformedURLException;
import java.security.GeneralSecurityException;
@@ -38,7 +37,6 @@ import org.onap.dmaap.mr.client.MRClientFactory;
import org.onap.dmaap.mr.client.impl.MRConsumerImpl;
import org.onap.dmaap.mr.client.response.MRConsumerResponse;
import org.onap.dmaap.mr.test.clients.ProtocolTypeConstants;
-import org.onap.policy.common.endpoints.event.comm.bus.DmaapTopicSinkFactory;
import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -52,9 +50,9 @@ public interface BusConsumer {
* fetch messages.
*
* @return list of messages
- * @throws Exception when error encountered by underlying libraries
+ * @throws IOException when error encountered by underlying libraries
*/
- public Iterable<String> fetch() throws InterruptedException, IOException;
+ public Iterable<String> fetch() throws IOException;
/**
* close underlying library consumer.
@@ -168,16 +166,24 @@ public interface BusConsumer {
}
@Override
- public Iterable<String> fetch() throws IOException, InterruptedException {
+ public Iterable<String> fetch() throws IOException {
try {
return getCurrentConsumer().fetch();
} catch (final IOException e) {
logger.error("{}: cannot fetch because of {} - backoff for {} ms.", this, e.getMessage(),
- this.fetchTimeout, e);
+ this.fetchTimeout);
+ sleepAfterFetchFailure();
+ throw e;
+ }
+ }
+ private void sleepAfterFetchFailure() {
+ try {
this.closeCondition.await(this.fetchTimeout, TimeUnit.MILLISECONDS);
- throw e;
+ } catch (InterruptedException e) {
+ logger.warn("{}: interrupted while handling fetch error", this, e);
+ Thread.currentThread().interrupt();
}
}
@@ -306,12 +312,12 @@ public interface BusConsumer {
}
@Override
- public Iterable<String> fetch() throws InterruptedException, IOException {
+ public Iterable<String> fetch() throws IOException {
final MRConsumerResponse response = this.consumer.fetchWithReturnConsumerResponse();
if (response == null) {
logger.warn("{}: DMaaP NULL response received", this);
- closeCondition.await(fetchTimeout, TimeUnit.MILLISECONDS);
+ sleepAfterFetchFailure();
return new ArrayList<>();
} else {
logger.debug("DMaaP consumer received {} : {}", response.getResponseCode(),
@@ -322,7 +328,7 @@ public interface BusConsumer {
logger.error("DMaaP consumer received: {} : {}", response.getResponseCode(),
response.getResponseMessage());
- closeCondition.await(fetchTimeout, TimeUnit.MILLISECONDS);
+ sleepAfterFetchFailure();
/* fall through */
}
@@ -335,6 +341,16 @@ public interface BusConsumer {
}
}
+ private void sleepAfterFetchFailure() {
+ try {
+ this.closeCondition.await(this.fetchTimeout, TimeUnit.MILLISECONDS);
+
+ } catch (InterruptedException e) {
+ logger.warn("{}: interrupted while handling fetch error", this, e);
+ Thread.currentThread().interrupt();
+ }
+ }
+
@Override
public void close() {
this.closeCondition.countDown();
@@ -434,7 +450,8 @@ public interface BusConsumer {
final String dme2RouteOffer = (busTopicParams.isAdditionalPropsValid()
- ? busTopicParams.getAdditionalProps().get(DmaapTopicSinkFactory.DME2_ROUTE_OFFER_PROPERTY)
+ ? busTopicParams.getAdditionalProps().get(
+ PolicyEndPointProperties.DME2_ROUTE_OFFER_PROPERTY)
: null);
if (busTopicParams.isEnvironmentInvalid()) {
@@ -474,7 +491,7 @@ public interface BusConsumer {
props = new Properties();
- props.setProperty(DmaapTopicSinkFactory.DME2_SERVICE_NAME_PROPERTY, serviceName);
+ props.setProperty(PolicyEndPointProperties.DME2_SERVICE_NAME_PROPERTY, serviceName);
props.setProperty("username", busTopicParams.getUserName());
props.setProperty("password", busTopicParams.getPassword());
@@ -489,7 +506,7 @@ public interface BusConsumer {
props.setProperty("Partner", busTopicParams.getPartner());
}
if (dme2RouteOffer != null) {
- props.setProperty(DmaapTopicSinkFactory.DME2_ROUTE_OFFER_PROPERTY, dme2RouteOffer);
+ props.setProperty(PolicyEndPointProperties.DME2_ROUTE_OFFER_PROPERTY, dme2RouteOffer);
}
props.setProperty("Latitude", busTopicParams.getLatitude());
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisher.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisher.java
index 67adf3b4..469794c7 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisher.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisher.java
@@ -26,7 +26,6 @@ import com.att.nsa.cambria.client.CambriaBatchingPublisher;
import com.att.nsa.cambria.client.CambriaClientBuilders;
import com.att.nsa.cambria.client.CambriaClientBuilders.PublisherBuilder;
import com.fasterxml.jackson.annotation.JsonIgnore;
-
import java.net.MalformedURLException;
import java.security.GeneralSecurityException;
import java.util.ArrayList;
@@ -34,12 +33,10 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
-
import org.apache.commons.lang3.StringUtils;
import org.onap.dmaap.mr.client.impl.MRSimplerBatchPublisher;
import org.onap.dmaap.mr.client.response.MRPublisherResponse;
import org.onap.dmaap.mr.test.clients.ProtocolTypeConstants;
-import org.onap.policy.common.endpoints.event.comm.bus.DmaapTopicSinkFactory;
import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.onap.policy.common.gson.annotation.GsonJsonIgnore;
import org.slf4j.Logger;
@@ -299,7 +296,8 @@ public interface BusPublisher {
busTopicParams.getUserName(),busTopicParams.getPassword(),busTopicParams.isUseHttps());
String dme2RouteOffer = busTopicParams.isAdditionalPropsValid()
- ? busTopicParams.getAdditionalProps().get(DmaapTopicSinkFactory.DME2_ROUTE_OFFER_PROPERTY)
+ ? busTopicParams.getAdditionalProps().get(
+ PolicyEndPointProperties.DME2_ROUTE_OFFER_PROPERTY)
: null;
validateParams(busTopicParams, dme2RouteOffer);
@@ -310,13 +308,13 @@ public interface BusPublisher {
props.setProperty("Environment", busTopicParams.getEnvironment());
props.setProperty("AFT_ENVIRONMENT", busTopicParams.getAftEnvironment());
- props.setProperty(DmaapTopicSinkFactory.DME2_SERVICE_NAME_PROPERTY, serviceName);
+ props.setProperty(PolicyEndPointProperties.DME2_SERVICE_NAME_PROPERTY, serviceName);
if (busTopicParams.getPartner() != null) {
props.setProperty("Partner", busTopicParams.getPartner());
}
if (dme2RouteOffer != null) {
- props.setProperty(DmaapTopicSinkFactory.DME2_ROUTE_OFFER_PROPERTY, dme2RouteOffer);
+ props.setProperty(PolicyEndPointProperties.DME2_ROUTE_OFFER_PROPERTY, dme2RouteOffer);
}
props.setProperty("Latitude", busTopicParams.getLatitude());
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSource.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSource.java
index 0953465b..164f2b16 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSource.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSource.java
@@ -29,6 +29,7 @@ import org.onap.policy.common.endpoints.event.comm.FilterableTopicSource;
import org.onap.policy.common.endpoints.event.comm.TopicListener;
import org.onap.policy.common.endpoints.event.comm.bus.BusTopicSource;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusConsumer.FilterableBusConsumer;
+import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.onap.policy.common.endpoints.utils.NetLoggerUtil;
import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
import org.onap.policy.common.utils.network.NetworkUtil;
@@ -103,13 +104,13 @@ public abstract class SingleThreadedBusTopicSource extends BusTopicBase
}
if (busTopicParams.getFetchTimeout() <= 0) {
- this.fetchTimeout = NO_TIMEOUT_MS_FETCH;
+ this.fetchTimeout = PolicyEndPointProperties.NO_TIMEOUT_MS_FETCH;
} else {
this.fetchTimeout = busTopicParams.getFetchTimeout();
}
if (busTopicParams.getFetchLimit() <= 0) {
- this.fetchLimit = NO_LIMIT_FETCH;
+ this.fetchLimit = PolicyEndPointProperties.NO_LIMIT_FETCH;
} else {
this.fetchLimit = busTopicParams.getFetchLimit();
}
@@ -225,7 +226,7 @@ public abstract class SingleThreadedBusTopicSource extends BusTopicBase
while (this.alive) {
try {
fetchAllMessages();
- } catch (Exception e) {
+ } catch (IOException | RuntimeException e) {
logger.error("{}: cannot fetch because of ", this, e.getMessage(), e);
}
}
@@ -233,7 +234,7 @@ public abstract class SingleThreadedBusTopicSource extends BusTopicBase
logger.info("{}: exiting thread", this);
}
- private void fetchAllMessages() throws InterruptedException, IOException {
+ private void fetchAllMessages() throws IOException {
for (String event : this.consumer.fetch()) {
synchronized (this) {
this.recentEvents.add(event);
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/client/TopicSinkClient.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/client/TopicSinkClient.java
index f08a1381..9f8b3c06 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/client/TopicSinkClient.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/client/TopicSinkClient.java
@@ -24,7 +24,7 @@ package org.onap.policy.common.endpoints.event.comm.client;
import java.util.List;
import lombok.Getter;
import lombok.NonNull;
-import org.onap.policy.common.endpoints.event.comm.TopicEndpoint;
+import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
@@ -109,6 +109,6 @@ public class TopicSinkClient {
* @return the sinks for the topic
*/
protected List<TopicSink> getTopicSinks(final String topic) {
- return TopicEndpoint.manager.getTopicSinks(topic);
+ return TopicEndpointManager.getManager().getTopicSinks(topic);
}
}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/features/NetLoggerFeatureApi.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/features/NetLoggerFeatureApi.java
index 4e7d4444..a99ecd26 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/features/NetLoggerFeatureApi.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/features/NetLoggerFeatureApi.java
@@ -23,7 +23,6 @@ package org.onap.policy.common.endpoints.features;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
import org.onap.policy.common.utils.services.OrderedService;
-import org.onap.policy.common.utils.services.OrderedServiceImpl;
import org.slf4j.Logger;
/**
@@ -32,12 +31,6 @@ import org.slf4j.Logger;
public interface NetLoggerFeatureApi extends OrderedService {
/**
- * Feature providers implementing this interface.
- */
- OrderedServiceImpl<NetLoggerFeatureApi> providers =
- new OrderedServiceImpl<>(NetLoggerFeatureApi.class);
-
- /**
* Intercepts a message before it is logged.
*
* @return true if this feature intercepts and takes ownership of the operation
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/features/NetLoggerFeatureProviders.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/features/NetLoggerFeatureProviders.java
new file mode 100644
index 00000000..db2b05d1
--- /dev/null
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/features/NetLoggerFeatureProviders.java
@@ -0,0 +1,41 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.endpoints.features;
+
+import lombok.Getter;
+import org.onap.policy.common.utils.services.OrderedServiceImpl;
+
+/**
+ * Providers for network logging feature.
+ */
+public class NetLoggerFeatureProviders {
+
+ /**
+ * Feature providers implementing this interface.
+ */
+ @Getter
+ private static OrderedServiceImpl<NetLoggerFeatureApi> providers =
+ new OrderedServiceImpl<>(NetLoggerFeatureApi.class);
+
+ private NetLoggerFeatureProviders() {
+ // do nothing
+ }
+}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClient.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClient.java
index 2e3b9afb..2fe46fb3 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClient.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClient.java
@@ -7,9 +7,9 @@
* 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.
@@ -33,11 +33,6 @@ import org.onap.policy.common.capabilities.Startable;
public interface HttpClient extends Startable {
/**
- * Factory.
- */
- HttpClientFactory factory = new IndexedHttpClientFactory();
-
- /**
* GET request.
*
* @param path context uri path.
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientConfigException.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientConfigException.java
new file mode 100644
index 00000000..98ec576f
--- /dev/null
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientConfigException.java
@@ -0,0 +1,44 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.endpoints.http.client;
+
+/**
+ * Exception generated by HttpClient builder.
+ */
+public class HttpClientConfigException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public HttpClientConfigException() {
+ super();
+ }
+
+ public HttpClientConfigException(String message) {
+ super(message);
+ }
+
+ public HttpClientConfigException(Throwable cause) {
+ super(cause);
+ }
+
+ public HttpClientConfigException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactory.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactory.java
index 5f4c4c9d..b155f729 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactory.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactory.java
@@ -8,9 +8,9 @@
* 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.
@@ -21,8 +21,6 @@
package org.onap.policy.common.endpoints.http.client;
-import java.security.KeyManagementException;
-import java.security.NoSuchAlgorithmException;
import java.util.List;
import java.util.Properties;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
@@ -35,17 +33,16 @@ public interface HttpClientFactory {
/**
* Build and http client with the following parameters.
*/
- HttpClient build(BusTopicParams busTopicParams)
- throws KeyManagementException, NoSuchAlgorithmException, ClassNotFoundException;
+ HttpClient build(BusTopicParams busTopicParams) throws HttpClientConfigException;
/**
* Build http client from properties.
*/
- List<HttpClient> build(Properties properties) throws KeyManagementException, NoSuchAlgorithmException;
+ List<HttpClient> build(Properties properties) throws HttpClientConfigException;
/**
* Get http client.
- *
+ *
* @param name the name
* @return the http client
*/
@@ -53,14 +50,14 @@ public interface HttpClientFactory {
/**
* List of http clients.
- *
+ *
* @return http clients
*/
List<HttpClient> inventory();
/**
* Destroy by name.
- *
+ *
* @param name name
*/
void destroy(String name);
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactoryInstance.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactoryInstance.java
new file mode 100644
index 00000000..c2921640
--- /dev/null
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactoryInstance.java
@@ -0,0 +1,37 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.endpoints.http.client;
+
+import lombok.Getter;
+
+public class HttpClientFactoryInstance {
+
+ /**
+ * The client factory.
+ */
+ @Getter
+ private static final HttpClientFactory clientFactory = new IndexedHttpClientFactory();
+
+
+ private HttpClientFactoryInstance() {
+ // do nothing
+ }
+}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/IndexedHttpClientFactory.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/IndexedHttpClientFactory.java
index c2d0e400..edf8ff6f 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/IndexedHttpClientFactory.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/IndexedHttpClientFactory.java
@@ -47,14 +47,17 @@ class IndexedHttpClientFactory implements HttpClientFactory {
protected HashMap<String, HttpClient> clients = new HashMap<>();
@Override
- public synchronized HttpClient build(BusTopicParams busTopicParams)
- throws KeyManagementException, NoSuchAlgorithmException, ClassNotFoundException {
+ public synchronized HttpClient build(BusTopicParams busTopicParams) throws HttpClientConfigException {
if (clients.containsKey(busTopicParams.getClientName())) {
return clients.get(busTopicParams.getClientName());
}
- JerseyClient client =
- new JerseyClient(busTopicParams);
+ JerseyClient client;
+ try {
+ client = new JerseyClient(busTopicParams);
+ } catch (KeyManagementException | NoSuchAlgorithmException | ClassNotFoundException e) {
+ throw new HttpClientConfigException(e);
+ }
if (busTopicParams.isManaged()) {
clients.put(busTopicParams.getClientName(), client);
@@ -64,8 +67,7 @@ class IndexedHttpClientFactory implements HttpClientFactory {
}
@Override
- public synchronized List<HttpClient> build(Properties properties)
- throws KeyManagementException, NoSuchAlgorithmException {
+ public synchronized List<HttpClient> build(Properties properties) throws HttpClientConfigException {
ArrayList<HttpClient> clientList = new ArrayList<>();
String clientNames = properties.getProperty(PolicyEndPointProperties.PROPERTY_HTTP_CLIENT_SERVICES);
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServer.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServer.java
index b674e265..73b1e544 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServer.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServer.java
@@ -7,9 +7,9 @@
* 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.
@@ -27,22 +27,16 @@ import org.onap.policy.common.capabilities.Startable;
*/
public interface HttpServletServer extends Startable {
-
- /**
- * Factory of Http Servlet Servers.
- */
- HttpServletServerFactory factory = new IndexedHttpServletServerFactory();
-
/**
* Get the port.
- *
+ *
* @return port
*/
int getPort();
/**
* Enables basic authentication with user and password on the the relative path relativeUriPath.
- *
+ *
* @param user user
* @param password password
* @param relativeUriPath relative path
@@ -63,7 +57,7 @@ public interface HttpServletServer extends Startable {
/**
* Sets the serialization provider to be used when classes are added to the service.
- *
+ *
* @param provider the provider to use for message serialization and de-serialization
*/
void setSerializationProvider(String provider);
@@ -78,10 +72,10 @@ public interface HttpServletServer extends Startable {
/**
* Adds a JAX-RS servlet class to serve REST requests.
- *
+ *
* @param servletPath servlet path
* @param restClass JAX-RS API Class
- *
+ *
* @throws IllegalArgumentException unable to process because of invalid input
* @throws IllegalStateException unable to process because of invalid state
*/
@@ -89,10 +83,10 @@ public interface HttpServletServer extends Startable {
/**
* Adds a package containing JAX-RS classes to serve REST requests.
- *
+ *
* @param servletPath servlet path
* @param restPackage JAX-RS package to scan
- *
+ *
* @throws IllegalArgumentException unable to process because of invalid input
* @throws IllegalStateException unable to process because of invalid state
*/
@@ -100,10 +94,10 @@ public interface HttpServletServer extends Startable {
/**
* Blocking start of the http server.
- *
+ *
* @param maxWaitTime max time to wait for the start to take place
* @return true if start was successful
- *
+ *
* @throws IllegalArgumentException if arguments are invalid
* @throws InterruptedException if the blocking operation is interrupted
*/
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServerFactoryInstance.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServerFactoryInstance.java
new file mode 100644
index 00000000..a56be701
--- /dev/null
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServerFactoryInstance.java
@@ -0,0 +1,38 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.endpoints.http.server;
+
+import lombok.Getter;
+
+public class HttpServletServerFactoryInstance {
+
+ /**
+ * The servlet factory.
+ */
+ @Getter
+ private static final HttpServletServerFactory serverFactory = new IndexedHttpServletServerFactory();
+
+
+ private HttpServletServerFactoryInstance() {
+ // do nothing
+ }
+
+}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyJerseyServer.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyJerseyServer.java
index 0aaf1ccb..78661a45 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyJerseyServer.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyJerseyServer.java
@@ -22,6 +22,7 @@ package org.onap.policy.common.endpoints.http.server.internal;
import io.swagger.jersey.config.JerseyJaxrsConfig;
import java.util.HashMap;
+import org.apache.commons.lang3.StringUtils;
import org.eclipse.jetty.servlet.ServletHolder;
import org.glassfish.jersey.server.ServerProperties;
import org.onap.policy.common.utils.network.NetworkUtil;
@@ -119,7 +120,7 @@ public class JettyJerseyServer extends JettyServletServer {
ServletHolder swaggerServlet = context.addServlet(JerseyJaxrsConfig.class, "/");
String hostname = this.connector.getHost();
- if (hostname == null || hostname.isEmpty() || hostname.equals(NetworkUtil.IPv4_WILDCARD_ADDRESS)) {
+ if (StringUtils.isBlank(hostname) || hostname.equals(NetworkUtil.IPV4_WILDCARD_ADDRESS)) {
hostname = NetworkUtil.getHostname();
}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/properties/PolicyEndPointProperties.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/properties/PolicyEndPointProperties.java
index 0d59fd2f..ed300422 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/properties/PolicyEndPointProperties.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/properties/PolicyEndPointProperties.java
@@ -7,9 +7,9 @@
* 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,86 +20,134 @@
package org.onap.policy.common.endpoints.properties;
-public interface PolicyEndPointProperties {
+public class PolicyEndPointProperties {
/* Generic property suffixes */
- String PROPERTY_TOPIC_SERVERS_SUFFIX = ".servers";
- String PROPERTY_TOPIC_TOPICS_SUFFIX = ".topics";
- String PROPERTY_TOPIC_API_KEY_SUFFIX = ".apiKey";
- String PROPERTY_TOPIC_API_SECRET_SUFFIX = ".apiSecret";
- String PROPERTY_TOPIC_AAF_MECHID_SUFFIX = ".aafMechId";
- String PROPERTY_TOPIC_AAF_PASSWORD_SUFFIX = ".aafPassword";
- String PROPERTY_TOPIC_EFFECTIVE_TOPIC_SUFFIX = ".effectiveTopic";
- String PROPERTY_TOPIC_EVENTS_SUFFIX = ".events";
- String PROPERTY_TOPIC_EVENTS_FILTER_SUFFIX = ".filter";
- String PROPERTY_TOPIC_EVENTS_CUSTOM_MODEL_CODER_GSON_SUFFIX = ".events.custom.gson";
+ public static final String PROPERTY_TOPIC_SERVERS_SUFFIX = ".servers";
+ public static final String PROPERTY_TOPIC_TOPICS_SUFFIX = ".topics";
+ public static final String PROPERTY_TOPIC_API_KEY_SUFFIX = ".apiKey";
+ public static final String PROPERTY_TOPIC_API_SECRET_SUFFIX = ".apiSecret";
+ public static final String PROPERTY_TOPIC_AAF_MECHID_SUFFIX = ".aafMechId";
+ public static final String PROPERTY_TOPIC_AAF_PASSWORD_SUFFIX = ".aafPassword";
+ public static final String PROPERTY_TOPIC_EFFECTIVE_TOPIC_SUFFIX = ".effectiveTopic";
+ public static final String PROPERTY_TOPIC_EVENTS_SUFFIX = ".events";
+ public static final String PROPERTY_TOPIC_EVENTS_FILTER_SUFFIX = ".filter";
+ public static final String PROPERTY_TOPIC_EVENTS_CUSTOM_MODEL_CODER_GSON_SUFFIX = ".events.custom.gson";
- String PROPERTY_TOPIC_SOURCE_CONSUMER_GROUP_SUFFIX = ".consumerGroup";
- String PROPERTY_TOPIC_SOURCE_CONSUMER_INSTANCE_SUFFIX = ".consumerInstance";
- String PROPERTY_TOPIC_SOURCE_FETCH_TIMEOUT_SUFFIX = ".fetchTimeout";
- String PROPERTY_TOPIC_SOURCE_FETCH_LIMIT_SUFFIX = ".fetchLimit";
- String PROPERTY_MANAGED_SUFFIX = ".managed";
- String PROPERTY_AAF_SUFFIX = ".aaf";
+ public static final String PROPERTY_TOPIC_SOURCE_CONSUMER_GROUP_SUFFIX = ".consumerGroup";
+ public static final String PROPERTY_TOPIC_SOURCE_CONSUMER_INSTANCE_SUFFIX = ".consumerInstance";
+ public static final String PROPERTY_TOPIC_SOURCE_FETCH_TIMEOUT_SUFFIX = ".fetchTimeout";
+ public static final String PROPERTY_TOPIC_SOURCE_FETCH_LIMIT_SUFFIX = ".fetchLimit";
+ public static final String PROPERTY_MANAGED_SUFFIX = ".managed";
+ public static final String PROPERTY_AAF_SUFFIX = ".aaf";
- String PROPERTY_TOPIC_SINK_PARTITION_KEY_SUFFIX = ".partitionKey";
+ public static final String PROPERTY_TOPIC_SINK_PARTITION_KEY_SUFFIX = ".partitionKey";
- String PROPERTY_ALLOW_SELF_SIGNED_CERTIFICATES_SUFFIX = ".selfSignedCertificates";
+ public static final String PROPERTY_ALLOW_SELF_SIGNED_CERTIFICATES_SUFFIX = ".selfSignedCertificates";
/* UEB Properties */
- String PROPERTY_UEB_SOURCE_TOPICS = "ueb.source.topics";
- String PROPERTY_UEB_SINK_TOPICS = "ueb.sink.topics";
+ public static final String PROPERTY_UEB_SOURCE_TOPICS = "ueb.source.topics";
+ public static final String PROPERTY_UEB_SINK_TOPICS = "ueb.sink.topics";
/* DMAAP Properties */
- String PROPERTY_DMAAP_SOURCE_TOPICS = "dmaap.source.topics";
- String PROPERTY_DMAAP_SINK_TOPICS = "dmaap.sink.topics";
-
- String PROPERTY_DMAAP_DME2_PARTNER_SUFFIX = ".dme2.partner";
- String PROPERTY_DMAAP_DME2_ROUTE_OFFER_SUFFIX = ".dme2.routeOffer";
- String PROPERTY_DMAAP_DME2_ENVIRONMENT_SUFFIX = ".dme2.environment";
- String PROPERTY_DMAAP_DME2_AFT_ENVIRONMENT_SUFFIX = ".dme2.aft.environment";
- String PROPERTY_DMAAP_DME2_LATITUDE_SUFFIX = ".dme2.latitude";
- String PROPERTY_DMAAP_DME2_LONGITUDE_SUFFIX = ".dme2.longitude";
-
- String PROPERTY_DMAAP_DME2_EP_READ_TIMEOUT_MS_SUFFIX = ".dme2.epReadTimeoutMs";
- String PROPERTY_DMAAP_DME2_EP_CONN_TIMEOUT_SUFFIX = ".dme2.epConnTimeout";
- String PROPERTY_DMAAP_DME2_ROUNDTRIP_TIMEOUT_MS_SUFFIX = ".dme2.roundtripTimeoutMs";
- String PROPERTY_DMAAP_DME2_VERSION_SUFFIX = ".dme2.version";
- String PROPERTY_DMAAP_DME2_SERVICE_NAME_SUFFIX = ".dme2.serviceName";
- String PROPERTY_DMAAP_DME2_SUB_CONTEXT_PATH_SUFFIX = ".dme2.subContextPath";
- String PROPERTY_DMAAP_DME2_SESSION_STICKINESS_REQUIRED_SUFFIX =
+ public static final String PROPERTY_DMAAP_SOURCE_TOPICS = "dmaap.source.topics";
+ public static final String PROPERTY_DMAAP_SINK_TOPICS = "dmaap.sink.topics";
+
+ public static final String PROPERTY_DMAAP_DME2_PARTNER_SUFFIX = ".dme2.partner";
+ public static final String PROPERTY_DMAAP_DME2_ROUTE_OFFER_SUFFIX = ".dme2.routeOffer";
+ public static final String PROPERTY_DMAAP_DME2_ENVIRONMENT_SUFFIX = ".dme2.environment";
+ public static final String PROPERTY_DMAAP_DME2_AFT_ENVIRONMENT_SUFFIX = ".dme2.aft.environment";
+ public static final String PROPERTY_DMAAP_DME2_LATITUDE_SUFFIX = ".dme2.latitude";
+ public static final String PROPERTY_DMAAP_DME2_LONGITUDE_SUFFIX = ".dme2.longitude";
+
+ public static final String PROPERTY_DMAAP_DME2_EP_READ_TIMEOUT_MS_SUFFIX = ".dme2.epReadTimeoutMs";
+ public static final String PROPERTY_DMAAP_DME2_EP_CONN_TIMEOUT_SUFFIX = ".dme2.epConnTimeout";
+ public static final String PROPERTY_DMAAP_DME2_ROUNDTRIP_TIMEOUT_MS_SUFFIX = ".dme2.roundtripTimeoutMs";
+ public static final String PROPERTY_DMAAP_DME2_VERSION_SUFFIX = ".dme2.version";
+ public static final String PROPERTY_DMAAP_DME2_SERVICE_NAME_SUFFIX = ".dme2.serviceName";
+ public static final String PROPERTY_DMAAP_DME2_SUB_CONTEXT_PATH_SUFFIX = ".dme2.subContextPath";
+ public static final String PROPERTY_DMAAP_DME2_SESSION_STICKINESS_REQUIRED_SUFFIX =
".dme2.sessionStickinessRequired";
- String PROPERTY_NOOP_SOURCE_TOPICS = "noop.source.topics";
- String PROPERTY_NOOP_SINK_TOPICS = "noop.sink.topics";
+ public static final String PROPERTY_NOOP_SOURCE_TOPICS = "noop.source.topics";
+ public static final String PROPERTY_NOOP_SINK_TOPICS = "noop.sink.topics";
/* HTTP Server Properties */
- String PROPERTY_HTTP_SERVER_SERVICES = "http.server.services";
+ public static final String PROPERTY_HTTP_SERVER_SERVICES = "http.server.services";
- String PROPERTY_HTTP_HOST_SUFFIX = ".host";
- String PROPERTY_HTTP_PORT_SUFFIX = ".port";
- String PROPERTY_HTTP_CONTEXT_URIPATH_SUFFIX = ".contextUriPath";
+ public static final String PROPERTY_HTTP_HOST_SUFFIX = ".host";
+ public static final String PROPERTY_HTTP_PORT_SUFFIX = ".port";
+ public static final String PROPERTY_HTTP_CONTEXT_URIPATH_SUFFIX = ".contextUriPath";
- String PROPERTY_HTTP_AUTH_USERNAME_SUFFIX = ".userName";
- String PROPERTY_HTTP_AUTH_PASSWORD_SUFFIX = ".password";
- String PROPERTY_HTTP_AUTH_URIPATH_SUFFIX = ".authUriPath";
+ public static final String PROPERTY_HTTP_AUTH_USERNAME_SUFFIX = ".userName";
+ public static final String PROPERTY_HTTP_AUTH_PASSWORD_SUFFIX = ".password";
+ public static final String PROPERTY_HTTP_AUTH_URIPATH_SUFFIX = ".authUriPath";
- String PROPERTY_HTTP_FILTER_CLASSES_SUFFIX = ".filterClasses";
- String PROPERTY_HTTP_REST_CLASSES_SUFFIX = ".restClasses";
- String PROPERTY_HTTP_REST_PACKAGES_SUFFIX = ".restPackages";
- String PROPERTY_HTTP_REST_URIPATH_SUFFIX = ".restUriPath";
+ public static final String PROPERTY_HTTP_FILTER_CLASSES_SUFFIX = ".filterClasses";
+ public static final String PROPERTY_HTTP_REST_CLASSES_SUFFIX = ".restClasses";
+ public static final String PROPERTY_HTTP_REST_PACKAGES_SUFFIX = ".restPackages";
+ public static final String PROPERTY_HTTP_REST_URIPATH_SUFFIX = ".restUriPath";
- String PROPERTY_HTTP_HTTPS_SUFFIX = ".https";
- String PROPERTY_HTTP_SWAGGER_SUFFIX = ".swagger";
+ public static final String PROPERTY_HTTP_HTTPS_SUFFIX = ".https";
+ public static final String PROPERTY_HTTP_SWAGGER_SUFFIX = ".swagger";
- String PROPERTY_HTTP_SERIALIZATION_PROVIDER = ".serialization.provider";
+ public static final String PROPERTY_HTTP_SERIALIZATION_PROVIDER = ".serialization.provider";
/* HTTP Client Properties */
- String PROPERTY_HTTP_CLIENT_SERVICES = "http.client.services";
+ public static final String PROPERTY_HTTP_CLIENT_SERVICES = "http.client.services";
- String PROPERTY_HTTP_URL_SUFFIX = PROPERTY_HTTP_CONTEXT_URIPATH_SUFFIX;
+ public static final String PROPERTY_HTTP_URL_SUFFIX = PROPERTY_HTTP_CONTEXT_URIPATH_SUFFIX;
+
+
+ /* DMaaP DME2 Topic Properties */
+
+ public static final String DME2_READ_TIMEOUT_PROPERTY = "AFT_DME2_EP_READ_TIMEOUT_MS";
+ public static final String DME2_EP_CONN_TIMEOUT_PROPERTY = "AFT_DME2_EP_CONN_TIMEOUT";
+ public static final String DME2_ROUNDTRIP_TIMEOUT_PROPERTY = "AFT_DME2_ROUNDTRIP_TIMEOUT_MS";
+ public static final String DME2_VERSION_PROPERTY = "Version";
+ public static final String DME2_ROUTE_OFFER_PROPERTY = "routeOffer";
+ public static final String DME2_SERVICE_NAME_PROPERTY = "ServiceName";
+ public static final String DME2_SUBCONTEXT_PATH_PROPERTY = "SubContextPath";
+ public static final String DME2_SESSION_STICKINESS_REQUIRED_PROPERTY = "sessionstickinessrequired";
+
+
+ /* Topic Sink Values */
+
+ /**
+ * Log Failures after X number of retries.
+ */
+ public static final int DEFAULT_LOG_SEND_FAILURES_AFTER = 1;
+
+
+ /* Topic Source values */
+
+ /**
+ * Default Timeout fetching in milliseconds.
+ */
+ public static final int DEFAULT_TIMEOUT_MS_FETCH = 15000;
+
+ /**
+ * Default maximum number of messages fetch at the time.
+ */
+ public static final int DEFAULT_LIMIT_FETCH = 100;
+
+ /**
+ * Definition of No Timeout fetching.
+ */
+ public static final int NO_TIMEOUT_MS_FETCH = -1;
+
+ /**
+ * Definition of No limit fetching.
+ */
+ public static final int NO_LIMIT_FETCH = -1;
+
+
+ private PolicyEndPointProperties() {
+ // do nothing
+ }
}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/DmaapPropertyUtils.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/DmaapPropertyUtils.java
index 6b44e5c8..7e0d3ff6 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/DmaapPropertyUtils.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/DmaapPropertyUtils.java
@@ -27,7 +27,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
-import org.onap.policy.common.endpoints.event.comm.bus.DmaapTopicSourceFactory;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams.TopicParamsBuilder;
import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
@@ -43,25 +42,25 @@ public class DmaapPropertyUtils {
Map<String,String> map = new HashMap<>();
map.put(PolicyEndPointProperties.PROPERTY_DMAAP_DME2_ROUTE_OFFER_SUFFIX,
- DmaapTopicSourceFactory.DME2_ROUTE_OFFER_PROPERTY);
+ PolicyEndPointProperties.DME2_ROUTE_OFFER_PROPERTY);
map.put(PolicyEndPointProperties.PROPERTY_DMAAP_DME2_EP_READ_TIMEOUT_MS_SUFFIX,
- DmaapTopicSourceFactory.DME2_READ_TIMEOUT_PROPERTY);
+ PolicyEndPointProperties.DME2_READ_TIMEOUT_PROPERTY);
map.put(PolicyEndPointProperties.PROPERTY_DMAAP_DME2_EP_CONN_TIMEOUT_SUFFIX,
- DmaapTopicSourceFactory.DME2_EP_CONN_TIMEOUT_PROPERTY);
+ PolicyEndPointProperties.DME2_EP_CONN_TIMEOUT_PROPERTY);
map.put(PolicyEndPointProperties.PROPERTY_DMAAP_DME2_ROUNDTRIP_TIMEOUT_MS_SUFFIX,
- DmaapTopicSourceFactory.DME2_ROUNDTRIP_TIMEOUT_PROPERTY);
+ PolicyEndPointProperties.DME2_ROUNDTRIP_TIMEOUT_PROPERTY);
map.put(PolicyEndPointProperties.PROPERTY_DMAAP_DME2_VERSION_SUFFIX,
- DmaapTopicSourceFactory.DME2_VERSION_PROPERTY);
+ PolicyEndPointProperties.DME2_VERSION_PROPERTY);
map.put(PolicyEndPointProperties.PROPERTY_DMAAP_DME2_SUB_CONTEXT_PATH_SUFFIX,
- DmaapTopicSourceFactory.DME2_SUBCONTEXT_PATH_PROPERTY);
+ PolicyEndPointProperties.DME2_SUBCONTEXT_PATH_PROPERTY);
map.put(PolicyEndPointProperties.PROPERTY_DMAAP_DME2_SESSION_STICKINESS_REQUIRED_SUFFIX,
- DmaapTopicSourceFactory.DME2_SESSION_STICKINESS_REQUIRED_PROPERTY);
+ PolicyEndPointProperties.DME2_SESSION_STICKINESS_REQUIRED_PROPERTY);
PROP_TO_DME = Collections.unmodifiableMap(map);
}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/NetLoggerUtil.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/NetLoggerUtil.java
index f82e6a8c..d8f48a26 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/NetLoggerUtil.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/NetLoggerUtil.java
@@ -22,6 +22,7 @@ package org.onap.policy.common.endpoints.utils;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.features.NetLoggerFeatureApi;
+import org.onap.policy.common.endpoints.features.NetLoggerFeatureProviders;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -110,7 +111,7 @@ public class NetLoggerUtil {
*/
private static boolean featureBeforeLog(Logger eventLogger, EventType type, CommInfrastructure protocol,
String topic, String message) {
- for (NetLoggerFeatureApi feature : NetLoggerFeatureApi.providers.getList()) {
+ for (NetLoggerFeatureApi feature : NetLoggerFeatureProviders.getProviders().getList()) {
try {
if (feature.beforeLog(eventLogger, type, protocol, topic, message)) {
return true;
@@ -137,7 +138,7 @@ public class NetLoggerUtil {
*/
private static boolean featureAfterLog(Logger eventLogger, EventType type, CommInfrastructure protocol,
String topic, String message) {
- for (NetLoggerFeatureApi feature : NetLoggerFeatureApi.providers.getList()) {
+ for (NetLoggerFeatureApi feature : NetLoggerFeatureProviders.getProviders().getList()) {
try {
if (feature.afterLog(eventLogger, type, protocol, topic, message)) {
return true;
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/ParameterUtils.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/ParameterUtils.java
index 40ce8fa5..cabfe58f 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/ParameterUtils.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/ParameterUtils.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 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.
@@ -32,7 +33,7 @@ import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
*
* @author Ajith Sreekumar (ajith.sreekumar@est.tech)
*/
-public abstract class ParameterUtils {
+public class ParameterUtils {
/**
* Private constructor used to prevent sub class instantiation.
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicFactoryTestBase.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicFactoryTestBase.java
index 67304f91..92d5a865 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicFactoryTestBase.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicFactoryTestBase.java
@@ -34,6 +34,7 @@ import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperti
import java.util.Map;
import org.onap.policy.common.endpoints.event.comm.Topic;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
+import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
/**
* Base class for DmaapTopicXxxFactory tests.
@@ -51,9 +52,9 @@ public abstract class DmaapTopicFactoryTestBase<T extends Topic> extends BusTopi
@Override
public void testBuildProperties() {
-
+
super.testBuildProperties();
-
+
// check properties specific to DMaaP/DME2
initFactory();
@@ -66,13 +67,13 @@ public abstract class DmaapTopicFactoryTestBase<T extends Topic> extends BusTopi
assertEquals(MY_PARTNER, params.getPartner());
Map<String, String> add = params.getAdditionalProps();
- assertEquals(MY_CONN_TIMEOUT, add.get(DmaapTopicSinkFactory.DME2_EP_CONN_TIMEOUT_PROPERTY));
- assertEquals(MY_READ_TIMEOUT, add.get(DmaapTopicSinkFactory.DME2_READ_TIMEOUT_PROPERTY));
- assertEquals(MY_ROUNDTRIP_TIMEOUT, add.get(DmaapTopicSinkFactory.DME2_ROUNDTRIP_TIMEOUT_PROPERTY));
- assertEquals(MY_ROUTE, add.get(DmaapTopicSinkFactory.DME2_ROUTE_OFFER_PROPERTY));
- assertEquals(MY_STICKINESS, add.get(DmaapTopicSinkFactory.DME2_SESSION_STICKINESS_REQUIRED_PROPERTY));
- assertEquals(MY_SUBCONTEXT, add.get(DmaapTopicSinkFactory.DME2_SUBCONTEXT_PATH_PROPERTY));
- assertEquals(MY_DME_VERSION, add.get(DmaapTopicSinkFactory.DME2_VERSION_PROPERTY));
+ assertEquals(MY_CONN_TIMEOUT, add.get(PolicyEndPointProperties.DME2_EP_CONN_TIMEOUT_PROPERTY));
+ assertEquals(MY_READ_TIMEOUT, add.get(PolicyEndPointProperties.DME2_READ_TIMEOUT_PROPERTY));
+ assertEquals(MY_ROUNDTRIP_TIMEOUT, add.get(PolicyEndPointProperties.DME2_ROUNDTRIP_TIMEOUT_PROPERTY));
+ assertEquals(MY_ROUTE, add.get(PolicyEndPointProperties.DME2_ROUTE_OFFER_PROPERTY));
+ assertEquals(MY_STICKINESS, add.get(PolicyEndPointProperties.DME2_SESSION_STICKINESS_REQUIRED_PROPERTY));
+ assertEquals(MY_SUBCONTEXT, add.get(PolicyEndPointProperties.DME2_SUBCONTEXT_PATH_PROPERTY));
+ assertEquals(MY_DME_VERSION, add.get(PolicyEndPointProperties.DME2_VERSION_PROPERTY));
}
@Override
@@ -81,23 +82,23 @@ public abstract class DmaapTopicFactoryTestBase<T extends Topic> extends BusTopi
// check "additional" properties
expectNullAddProp(PROPERTY_DMAAP_DME2_EP_CONN_TIMEOUT_SUFFIX,
- DmaapTopicSinkFactory.DME2_EP_CONN_TIMEOUT_PROPERTY);
+ PolicyEndPointProperties.DME2_EP_CONN_TIMEOUT_PROPERTY);
expectNullAddProp(PROPERTY_DMAAP_DME2_EP_READ_TIMEOUT_MS_SUFFIX,
- DmaapTopicSinkFactory.DME2_READ_TIMEOUT_PROPERTY);
+ PolicyEndPointProperties.DME2_READ_TIMEOUT_PROPERTY);
expectNullAddProp(PROPERTY_DMAAP_DME2_ROUNDTRIP_TIMEOUT_MS_SUFFIX,
- DmaapTopicSinkFactory.DME2_ROUNDTRIP_TIMEOUT_PROPERTY);
+ PolicyEndPointProperties.DME2_ROUNDTRIP_TIMEOUT_PROPERTY);
- expectNullAddProp(PROPERTY_DMAAP_DME2_ROUTE_OFFER_SUFFIX, DmaapTopicSinkFactory.DME2_ROUTE_OFFER_PROPERTY);
+ expectNullAddProp(PROPERTY_DMAAP_DME2_ROUTE_OFFER_SUFFIX, PolicyEndPointProperties.DME2_ROUTE_OFFER_PROPERTY);
expectNullAddProp(PROPERTY_DMAAP_DME2_SESSION_STICKINESS_REQUIRED_SUFFIX,
- DmaapTopicSinkFactory.DME2_SESSION_STICKINESS_REQUIRED_PROPERTY);
+ PolicyEndPointProperties.DME2_SESSION_STICKINESS_REQUIRED_PROPERTY);
expectNullAddProp(PROPERTY_DMAAP_DME2_SUB_CONTEXT_PATH_SUFFIX,
- DmaapTopicSinkFactory.DME2_SUBCONTEXT_PATH_PROPERTY);
+ PolicyEndPointProperties.DME2_SUBCONTEXT_PATH_PROPERTY);
- expectNullAddProp(PROPERTY_DMAAP_DME2_VERSION_SUFFIX, DmaapTopicSinkFactory.DME2_VERSION_PROPERTY);
+ expectNullAddProp(PROPERTY_DMAAP_DME2_VERSION_SUFFIX, PolicyEndPointProperties.DME2_VERSION_PROPERTY);
}
@Override
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkTest.java
index 52ba3e9e..9136108a 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP Policy Engine - Common Modules
* ================================================================================
- * 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.
@@ -28,7 +28,7 @@ public class DmaapTopicSinkTest {
@Test
public void test() {
- assertNotNull(DmaapTopicSink.factory);
+ assertNotNull(DmaapTopicFactories.getSinkFactory());
}
}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceFactoryTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceFactoryTest.java
index d6187420..b4c2f758 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceFactoryTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceFactoryTest.java
@@ -35,6 +35,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
+import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
public class DmaapTopicSourceFactoryTest extends DmaapTopicFactoryTestBase<DmaapTopicSource> {
@@ -80,11 +81,11 @@ public class DmaapTopicSourceFactoryTest extends DmaapTopicFactoryTestBase<Dmaap
// check default values for source-specific parameters
checkDefault(PROPERTY_TOPIC_SOURCE_FETCH_LIMIT_SUFFIX,
- params2 -> params2.getFetchLimit() == DmaapTopicSource.DEFAULT_LIMIT_FETCH,
+ params2 -> params2.getFetchLimit() == PolicyEndPointProperties.DEFAULT_LIMIT_FETCH,
null, "", "invalid-limit-number");
checkDefault(PROPERTY_TOPIC_SOURCE_FETCH_TIMEOUT_SUFFIX,
- params2 -> params2.getFetchTimeout() == DmaapTopicSource.DEFAULT_TIMEOUT_MS_FETCH,
+ params2 -> params2.getFetchTimeout() == PolicyEndPointProperties.DEFAULT_TIMEOUT_MS_FETCH,
null, "", "invalid-timeout-number");
}
@@ -97,8 +98,8 @@ public class DmaapTopicSourceFactoryTest extends DmaapTopicFactoryTestBase<Dmaap
BusTopicParams params = factory.params.getFirst();
assertEquals(MY_API_KEY, params.getApiKey());
assertEquals(MY_API_SECRET, params.getApiSecret());
- assertEquals(DmaapTopicSource.DEFAULT_LIMIT_FETCH, params.getFetchLimit());
- assertEquals(DmaapTopicSource.DEFAULT_TIMEOUT_MS_FETCH, params.getFetchTimeout());
+ assertEquals(PolicyEndPointProperties.DEFAULT_LIMIT_FETCH, params.getFetchLimit());
+ assertEquals(PolicyEndPointProperties.DEFAULT_TIMEOUT_MS_FETCH, params.getFetchTimeout());
}
@Test
@@ -110,8 +111,8 @@ public class DmaapTopicSourceFactoryTest extends DmaapTopicFactoryTestBase<Dmaap
BusTopicParams params = factory.params.getFirst();
assertEquals(null, params.getApiKey());
assertEquals(null, params.getApiSecret());
- assertEquals(DmaapTopicSource.DEFAULT_LIMIT_FETCH, params.getFetchLimit());
- assertEquals(DmaapTopicSource.DEFAULT_TIMEOUT_MS_FETCH, params.getFetchTimeout());
+ assertEquals(PolicyEndPointProperties.DEFAULT_LIMIT_FETCH, params.getFetchLimit());
+ assertEquals(PolicyEndPointProperties.DEFAULT_TIMEOUT_MS_FETCH, params.getFetchTimeout());
}
@Test
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceTest.java
index 6828444a..1735e2ee 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP Policy Engine - Common Modules
* ================================================================================
- * 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.
@@ -28,7 +28,7 @@ public class DmaapTopicSourceTest {
@Test
public void test() {
- assertNotNull(DmaapTopicSource.factory);
+ assertNotNull(DmaapTopicFactories.getSourceFactory());
}
}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSinkTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSinkTest.java
index 3e7aca01..77452604 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSinkTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSinkTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP Policy Engine - Common Modules
* ================================================================================
- * 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.
@@ -28,7 +28,7 @@ public class UebTopicSinkTest {
@Test
public void test() {
- assertNotNull(UebTopicSink.factory);
+ assertNotNull(UebTopicFactories.getSinkFactory());
}
}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSourceFactoryTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSourceFactoryTest.java
index 468805de..81e30756 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSourceFactoryTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSourceFactoryTest.java
@@ -35,6 +35,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
+import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
public class UebTopicSourceFactoryTest extends UebTopicFactoryTestBase<UebTopicSource> {
@@ -81,11 +82,11 @@ public class UebTopicSourceFactoryTest extends UebTopicFactoryTestBase<UebTopicS
// check default values for source-specific parameters
checkDefault(PROPERTY_TOPIC_SOURCE_FETCH_LIMIT_SUFFIX,
- params2 -> params2.getFetchLimit() == UebTopicSource.DEFAULT_LIMIT_FETCH,
+ params2 -> params2.getFetchLimit() == PolicyEndPointProperties.DEFAULT_LIMIT_FETCH,
null, "", "invalid-limit-number");
checkDefault(PROPERTY_TOPIC_SOURCE_FETCH_TIMEOUT_SUFFIX,
- params2 -> params2.getFetchTimeout() == UebTopicSource.DEFAULT_TIMEOUT_MS_FETCH,
+ params2 -> params2.getFetchTimeout() == PolicyEndPointProperties.DEFAULT_TIMEOUT_MS_FETCH,
null, "", "invalid-timeout-number");
}
@@ -98,8 +99,8 @@ public class UebTopicSourceFactoryTest extends UebTopicFactoryTestBase<UebTopicS
BusTopicParams params = factory.params.getFirst();
assertEquals(MY_API_KEY, params.getApiKey());
assertEquals(MY_API_SECRET, params.getApiSecret());
- assertEquals(UebTopicSource.DEFAULT_LIMIT_FETCH, params.getFetchLimit());
- assertEquals(UebTopicSource.DEFAULT_TIMEOUT_MS_FETCH, params.getFetchTimeout());
+ assertEquals(PolicyEndPointProperties.DEFAULT_LIMIT_FETCH, params.getFetchLimit());
+ assertEquals(PolicyEndPointProperties.DEFAULT_TIMEOUT_MS_FETCH, params.getFetchTimeout());
}
@Test
@@ -111,8 +112,8 @@ public class UebTopicSourceFactoryTest extends UebTopicFactoryTestBase<UebTopicS
BusTopicParams params = factory.params.getFirst();
assertEquals(null, params.getApiKey());
assertEquals(null, params.getApiSecret());
- assertEquals(UebTopicSource.DEFAULT_LIMIT_FETCH, params.getFetchLimit());
- assertEquals(UebTopicSource.DEFAULT_TIMEOUT_MS_FETCH, params.getFetchTimeout());
+ assertEquals(PolicyEndPointProperties.DEFAULT_LIMIT_FETCH, params.getFetchLimit());
+ assertEquals(PolicyEndPointProperties.DEFAULT_TIMEOUT_MS_FETCH, params.getFetchTimeout());
assertEquals(true, params.isAllowSelfSignedCerts());
}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSourceTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSourceTest.java
index 11bb3f4d..9ef8af84 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSourceTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSourceTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP Policy Engine - Common Modules
* ================================================================================
- * 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.
@@ -28,7 +28,7 @@ public class UebTopicSourceTest {
@Test
public void test() {
- assertNotNull(UebTopicSource.factory);
+ assertNotNull(UebTopicFactories.getSourceFactory());
}
}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumerTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumerTest.java
index a32083fa..0255c100 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumerTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumerTest.java
@@ -91,10 +91,6 @@ public class BusConsumerTest extends TopicTestBase {
} catch (IOException e) {
assertEquals(ex, e);
-
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- assertEquals(ex, e);
}
}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/client/TopicSinkClientTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/client/TopicSinkClientTest.java
index 07630cd4..e30f38a7 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/client/TopicSinkClientTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/client/TopicSinkClientTest.java
@@ -38,7 +38,7 @@ import java.util.concurrent.atomic.AtomicReference;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
-import org.onap.policy.common.endpoints.event.comm.TopicEndpoint;
+import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
public class TopicSinkClientTest {
@@ -66,14 +66,14 @@ public class TopicSinkClientTest {
props.setProperty("noop.sink.topics", TOPIC);
// clear all topics and then configure one topic
- TopicEndpoint.manager.shutdown();
- TopicEndpoint.manager.addTopicSinks(props);
+ TopicEndpointManager.getManager().shutdown();
+ TopicEndpointManager.getManager().addTopicSinks(props);
}
@AfterClass
public static void tearDown() {
// clear all topics after the tests
- TopicEndpoint.manager.shutdown();
+ TopicEndpointManager.getManager().shutdown();
}
/**
@@ -82,7 +82,7 @@ public class TopicSinkClientTest {
@Test
public void testGetTopicSinks() throws Exception {
- sink = TopicEndpoint.manager.getNoopTopicSink(TOPIC);
+ sink = TopicEndpointManager.getManager().getNoopTopicSink(TOPIC);
assertNotNull(sink);
final AtomicReference<String> evref = new AtomicReference<>(null);
@@ -106,7 +106,7 @@ public class TopicSinkClientTest {
@Test
public void testTopicSinkClient_GetTopic() throws TopicSinkClientException {
- assertEquals(TOPIC, new TopicSinkClient(TopicEndpoint.manager.getNoopTopicSink(TOPIC)).getTopic());
+ assertEquals(TOPIC, new TopicSinkClient(TopicEndpointManager.getManager().getNoopTopicSink(TOPIC)).getTopic());
assertEquals(TOPIC, new TopicSinkClient(TOPIC).getTopic());
assertThatThrownBy(() -> new TopicSinkClient((TopicSink) null)).isInstanceOf(IllegalArgumentException.class);
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java
index f559b112..2aaf1367 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java
@@ -25,8 +25,6 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import java.security.KeyManagementException;
-import java.security.NoSuchAlgorithmException;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -40,7 +38,10 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
import org.onap.policy.common.endpoints.http.client.HttpClient;
+import org.onap.policy.common.endpoints.http.client.HttpClientConfigException;
+import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.common.endpoints.http.server.HttpServletServer;
+import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
import org.onap.policy.common.endpoints.http.server.internal.JettyJerseyServer;
import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.onap.policy.common.utils.network.NetworkUtil;
@@ -72,7 +73,7 @@ public class HttpClientTest {
/* echo server - http + no auth */
final HttpServletServer echoServerNoAuth =
- HttpServletServer.factory.build("echo", LOCALHOST, 6666, "/", false, true);
+ HttpServletServerFactoryInstance.getServerFactory().build("echo", LOCALHOST, 6666, "/", false, true);
echoServerNoAuth.addServletPackage("/*", HttpClientTest.class.getPackage().getName());
echoServerNoAuth.waitedStart(5000);
@@ -112,8 +113,8 @@ public class HttpClientTest {
/* echo server - https + basic auth */
- final HttpServletServer echoServerAuth =
- HttpServletServer.factory.build("echo", true, LOCALHOST, 6667, "/", false, true);
+ final HttpServletServer echoServerAuth = HttpServletServerFactoryInstance.getServerFactory()
+ .build("echo", true, LOCALHOST, 6667, "/", false, true);
echoServerAuth.setBasicAuthentication("x", "y", null);
echoServerAuth.addServletPackage("/*", HttpClientTest.class.getPackage().getName());
echoServerAuth.addFilterClass("/*", TestFilter.class.getName());
@@ -132,7 +133,7 @@ public class HttpClientTest {
*/
@Before
public void setUp() {
- HttpClient.factory.destroy();
+ HttpClientFactoryInstance.getClientFactory().destroy();
MyGsonProvider.resetSome();
MyJacksonProvider.resetSome();
@@ -143,8 +144,8 @@ public class HttpClientTest {
*/
@AfterClass
public static void tearDownAfterClass() {
- HttpServletServer.factory.destroy();
- HttpClient.factory.destroy();
+ HttpServletServerFactoryInstance.getServerFactory().destroy();
+ HttpClientFactoryInstance.getClientFactory().destroy();
if (savedValuesMap.containsKey(JettyJerseyServer.SYSTEM_KEYSTORE_PROPERTY_NAME)) {
System.setProperty(JettyJerseyServer.SYSTEM_KEYSTORE_PROPERTY_NAME,
@@ -254,10 +255,11 @@ public class HttpClientTest {
@Test
public void testHttpPutAuthClient_JacksonProvider() throws Exception {
- final HttpClient client = HttpClient.factory.build(BusTopicParams.builder().clientName(TEST_HTTP_AUTH_CLIENT)
- .useHttps(true).allowSelfSignedCerts(true).hostname(LOCALHOST).port(6667)
- .basePath(JUNIT_ECHO).userName("x").password("y").managed(true)
- .serializationProvider(MyJacksonProvider.class.getName()).build());
+ final HttpClient client = HttpClientFactoryInstance.getClientFactory()
+ .build(BusTopicParams.builder().clientName(TEST_HTTP_AUTH_CLIENT).useHttps(true)
+ .allowSelfSignedCerts(true).hostname(LOCALHOST).port(6667).basePath(JUNIT_ECHO)
+ .userName("x").password("y").managed(true)
+ .serializationProvider(MyJacksonProvider.class.getName()).build());
Entity<MyEntity> entity = Entity.entity(new MyEntity(MY_VALUE), MediaType.APPLICATION_JSON);
final Response response = client.put(HELLO, entity, Collections.emptyMap());
@@ -273,10 +275,11 @@ public class HttpClientTest {
@Test
public void testHttpPutAuthClient_GsonProvider() throws Exception {
- final HttpClient client = HttpClient.factory.build(BusTopicParams.builder().clientName(TEST_HTTP_AUTH_CLIENT)
- .useHttps(true).allowSelfSignedCerts(true).hostname(LOCALHOST).port(6667)
- .basePath(JUNIT_ECHO).userName("x").password("y").managed(true)
- .serializationProvider(MyGsonProvider.class.getName()).build());
+ final HttpClient client = HttpClientFactoryInstance.getClientFactory()
+ .build(BusTopicParams.builder().clientName(TEST_HTTP_AUTH_CLIENT).useHttps(true)
+ .allowSelfSignedCerts(true).hostname(LOCALHOST).port(6667).basePath(JUNIT_ECHO)
+ .userName("x").password("y").managed(true)
+ .serializationProvider(MyGsonProvider.class.getName()).build());
Entity<MyEntity> entity = Entity.entity(new MyEntity(MY_VALUE), MediaType.APPLICATION_JSON);
final Response response = client.put(HELLO, entity, Collections.emptyMap());
@@ -368,21 +371,22 @@ public class HttpClientTest {
httpProperties.setProperty(PolicyEndPointProperties.PROPERTY_HTTP_CLIENT_SERVICES + DOT_PDP
+ PolicyEndPointProperties.PROPERTY_MANAGED_SUFFIX, "true");
- final List<HttpServletServer> servers = HttpServletServer.factory.build(httpProperties);
+ final List<HttpServletServer> servers =
+ HttpServletServerFactoryInstance.getServerFactory().build(httpProperties);
assertEquals(2, servers.size());
- final List<HttpClient> clients = HttpClient.factory.build(httpProperties);
+ final List<HttpClient> clients = HttpClientFactoryInstance.getClientFactory().build(httpProperties);
assertEquals(2, clients.size());
for (final HttpServletServer server : servers) {
server.waitedStart(10000);
}
- final HttpClient clientPap = HttpClient.factory.get("PAP");
+ final HttpClient clientPap = HttpClientFactoryInstance.getClientFactory().get("PAP");
final Response response = clientPap.get();
assertEquals(200, response.getStatus());
- final HttpClient clientPdp = HttpClient.factory.get("PDP");
+ final HttpClient clientPdp = HttpClientFactoryInstance.getClientFactory().get("PDP");
final Response response2 = clientPdp.get("test");
assertEquals(500, response2.getStatus());
@@ -425,7 +429,7 @@ public class HttpClientTest {
+ PolicyEndPointProperties.PROPERTY_HTTP_SERIALIZATION_PROVIDER,
MyJacksonProvider.class.getName());
- final List<HttpClient> clients = HttpClient.factory.build(httpProperties);
+ final List<HttpClient> clients = HttpClientFactoryInstance.getClientFactory().build(httpProperties);
assertEquals(2, clients.size());
Entity<MyEntity> entity = Entity.entity(new MyEntity(MY_VALUE), MediaType.APPLICATION_JSON);
@@ -433,7 +437,7 @@ public class HttpClientTest {
// use gson client
MyGsonProvider.resetSome();
MyJacksonProvider.resetSome();
- HttpClient client = HttpClient.factory.get("GSON");
+ HttpClient client = HttpClientFactoryInstance.getClientFactory().get("GSON");
Response response = client.put(HELLO, entity, Collections.emptyMap());
String body = HttpClient.getBody(response, String.class);
@@ -447,7 +451,7 @@ public class HttpClientTest {
// use jackson client
MyGsonProvider.resetSome();
MyJacksonProvider.resetSome();
- client = HttpClient.factory.get("JACKSON");
+ client = HttpClientFactoryInstance.getClientFactory().get("JACKSON");
response = client.put(HELLO, entity, Collections.emptyMap());
body = HttpClient.getBody(response, String.class);
@@ -459,18 +463,19 @@ public class HttpClientTest {
assertFalse(MyGsonProvider.hasWrittenSome());
}
- private HttpClient getAuthHttpClient()
- throws KeyManagementException, NoSuchAlgorithmException, ClassNotFoundException {
- return HttpClient.factory.build(BusTopicParams.builder().clientName(TEST_HTTP_AUTH_CLIENT)
- .useHttps(true).allowSelfSignedCerts(true).hostname(LOCALHOST).port(6667).basePath(JUNIT_ECHO)
- .userName("x").password("y").managed(true).build());
+ private HttpClient getAuthHttpClient() throws HttpClientConfigException {
+ return HttpClientFactoryInstance.getClientFactory()
+ .build(BusTopicParams.builder().clientName(TEST_HTTP_AUTH_CLIENT).useHttps(true)
+ .allowSelfSignedCerts(true).hostname(LOCALHOST).port(6667).basePath(JUNIT_ECHO)
+ .userName("x").password("y").managed(true).build());
}
private HttpClient getNoAuthHttpClient(String clientName, boolean https, int port)
- throws KeyManagementException, NoSuchAlgorithmException, ClassNotFoundException {
- return HttpClient.factory.build(BusTopicParams.builder().clientName(clientName)
- .useHttps(https).allowSelfSignedCerts(https).hostname(LOCALHOST).port(port).basePath(JUNIT_ECHO)
- .userName(null).password(null).managed(true).build());
+ throws HttpClientConfigException {
+ return HttpClientFactoryInstance.getClientFactory()
+ .build(BusTopicParams.builder().clientName(clientName).useHttps(https)
+ .allowSelfSignedCerts(https).hostname(LOCALHOST).port(port).basePath(JUNIT_ECHO)
+ .userName(null).password(null).managed(true).build());
}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpExceptionsTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpExceptionsTest.java
new file mode 100644
index 00000000..85135759
--- /dev/null
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpExceptionsTest.java
@@ -0,0 +1,33 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.endpoints.http.server.test;
+
+import org.junit.Test;
+import org.onap.policy.common.endpoints.http.client.HttpClientConfigException;
+import org.onap.policy.common.utils.test.ExceptionsTester;
+
+public class HttpExceptionsTest extends ExceptionsTester {
+
+ @Test
+ public void testHttpClientConfigException() {
+ test(HttpClientConfigException.class);
+ }
+}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java
index c6ff2f32..f2b53648 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java
@@ -39,6 +39,7 @@ import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.common.endpoints.http.server.HttpServletServer;
+import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
import org.onap.policy.common.utils.gson.GsonTestUtils;
import org.onap.policy.common.utils.network.NetworkUtil;
import org.slf4j.Logger;
@@ -79,7 +80,7 @@ public class HttpServerTest {
incrementPort();
portUrl = LOCALHOST_PREFIX + port;
- HttpServletServer.factory.destroy();
+ HttpServletServerFactoryInstance.getServerFactory().destroy();
MyJacksonProvider.resetSome();
MyGsonProvider.resetSome();
@@ -91,19 +92,20 @@ public class HttpServerTest {
@AfterClass
public static void tearDownAfterClass() {
- HttpServletServer.factory.destroy();
+ HttpServletServerFactoryInstance.getServerFactory().destroy();
}
@Test
public void testDefaultPackageServer() throws Exception {
logger.info("-- testDefaultPackageServer() --");
- HttpServletServer server = HttpServletServer.factory.build("echo", LOCALHOST, port, "/", false, true);
+ HttpServletServer server = HttpServletServerFactoryInstance.getServerFactory()
+ .build("echo", LOCALHOST, port, "/", false, true);
server.addServletPackage("/*", this.getClass().getPackage().getName());
server.addFilterClass("/*", TestFilter.class.getName());
server.waitedStart(5000);
- assertTrue(HttpServletServer.factory.get(port).isAlive());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
RestEchoReqResp request = new RestEchoReqResp();
request.setRequestId(100);
@@ -118,14 +120,15 @@ public class HttpServerTest {
public void testJacksonPackageServer() throws Exception {
logger.info("-- testJacksonPackageServer() --");
- HttpServletServer server = HttpServletServer.factory.build("echo", LOCALHOST, port, "/", false, true);
+ HttpServletServer server = HttpServletServerFactoryInstance.getServerFactory()
+ .build("echo", LOCALHOST, port, "/", false, true);
server.setSerializationProvider(MyJacksonProvider.class.getName());
server.addServletPackage("/*", this.getClass().getPackage().getName());
server.addFilterClass("/*", TestFilter.class.getName());
server.waitedStart(5000);
- assertTrue(HttpServletServer.factory.get(port).isAlive());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
RestEchoReqResp request = new RestEchoReqResp();
request.setRequestId(100);
@@ -146,14 +149,15 @@ public class HttpServerTest {
public void testGsonPackageServer() throws Exception {
logger.info("-- testGsonPackageServer() --");
- HttpServletServer server = HttpServletServer.factory.build("echo", LOCALHOST, port, "/", false, true);
+ HttpServletServer server = HttpServletServerFactoryInstance.getServerFactory()
+ .build("echo", LOCALHOST, port, "/", false, true);
server.setSerializationProvider(MyGsonProvider.class.getName());
server.addServletPackage("/*", this.getClass().getPackage().getName());
server.addFilterClass("/*", TestFilter.class.getName());
server.waitedStart(5000);
- assertTrue(HttpServletServer.factory.get(port).isAlive());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
RestEchoReqResp request = new RestEchoReqResp();
request.setRequestId(100);
@@ -174,12 +178,13 @@ public class HttpServerTest {
public void testDefaultClassServer() throws Exception {
logger.info("-- testDefaultClassServer() --");
- HttpServletServer server = HttpServletServer.factory.build("echo", LOCALHOST, port, "/", false, true);
+ HttpServletServer server = HttpServletServerFactoryInstance.getServerFactory()
+ .build("echo", LOCALHOST, port, "/", false, true);
server.addServletClass("/*", RestEchoService.class.getName());
server.addFilterClass("/*", TestFilter.class.getName());
server.waitedStart(5000);
- assertTrue(HttpServletServer.factory.get(port).isAlive());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
RestEchoReqResp request = new RestEchoReqResp();
request.setRequestId(100);
@@ -194,13 +199,14 @@ public class HttpServerTest {
public void testJacksonClassServer() throws Exception {
logger.info("-- testJacksonClassServer() --");
- HttpServletServer server = HttpServletServer.factory.build("echo", LOCALHOST, port, "/", false, true);
+ HttpServletServer server = HttpServletServerFactoryInstance.getServerFactory()
+ .build("echo", LOCALHOST, port, "/", false, true);
server.setSerializationProvider(MyJacksonProvider.class.getName());
server.addServletClass("/*", RestEchoService.class.getName());
server.addFilterClass("/*", TestFilter.class.getName());
server.waitedStart(5000);
- assertTrue(HttpServletServer.factory.get(port).isAlive());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
RestEchoReqResp request = new RestEchoReqResp();
request.setRequestId(100);
@@ -221,13 +227,14 @@ public class HttpServerTest {
public void testGsonClassServer() throws Exception {
logger.info("-- testGsonClassServer() --");
- HttpServletServer server = HttpServletServer.factory.build("echo", LOCALHOST, port, "/", false, true);
+ HttpServletServer server = HttpServletServerFactoryInstance.getServerFactory()
+ .build("echo", LOCALHOST, port, "/", false, true);
server.setSerializationProvider(MyGsonProvider.class.getName());
server.addServletClass("/*", RestEchoService.class.getName());
server.addFilterClass("/*", TestFilter.class.getName());
server.waitedStart(5000);
- assertTrue(HttpServletServer.factory.get(port).isAlive());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
RestEchoReqResp request = new RestEchoReqResp();
request.setRequestId(100);
@@ -246,7 +253,8 @@ public class HttpServerTest {
@Test
public void testSerialize() {
- HttpServletServer server = HttpServletServer.factory.build("echo", LOCALHOST, port, "/", false, true);
+ HttpServletServer server = HttpServletServerFactoryInstance.getServerFactory()
+ .build("echo", LOCALHOST, port, "/", false, true);
server.addServletPackage("/*", this.getClass().getPackage().getName());
server.addFilterClass("/*", TestFilter.class.getName());
@@ -258,13 +266,14 @@ public class HttpServerTest {
public void testSingleServer() throws Exception {
logger.info("-- testSingleServer() --");
- HttpServletServer server = HttpServletServer.factory.build("echo", LOCALHOST, port, "/", false, true);
+ HttpServletServer server = HttpServletServerFactoryInstance.getServerFactory()
+ .build("echo", LOCALHOST, port, "/", false, true);
server.addServletPackage("/*", this.getClass().getPackage().getName());
server.addFilterClass("/*", TestFilter.class.getName());
server.waitedStart(5000);
- assertTrue(HttpServletServer.factory.get(port).isAlive());
- assertFalse(HttpServletServer.factory.get(port).isAaf());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
+ assertFalse(HttpServletServerFactoryInstance.getServerFactory().get(port).isAaf());
String response = http(portUrl + JUNIT_ECHO_HELLO);
assertEquals(HELLO, response);
@@ -274,32 +283,34 @@ public class HttpServerTest {
response = http(portUrl + "/junit/echo/hello?block=true");
assertEquals("FILTERED", response);
- assertTrue(HttpServletServer.factory.get(port).isAlive());
- assertEquals(1, HttpServletServer.factory.inventory().size());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
+ assertEquals(1, HttpServletServerFactoryInstance.getServerFactory().inventory().size());
server.setAafAuthentication("/*");
- assertTrue(HttpServletServer.factory.get(port).isAaf());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAaf());
- HttpServletServer.factory.destroy(port);
- assertEquals(0, HttpServletServer.factory.inventory().size());
+ HttpServletServerFactoryInstance.getServerFactory().destroy(port);
+ assertEquals(0, HttpServletServerFactoryInstance.getServerFactory().inventory().size());
}
@Test
public void testMultipleServers() throws Exception {
logger.info("-- testMultipleServers() --");
- HttpServletServer server1 = HttpServletServer.factory.build("echo-1", false,LOCALHOST, port, "/", true, true);
+ HttpServletServer server1 = HttpServletServerFactoryInstance.getServerFactory()
+ .build("echo-1", false,LOCALHOST, port, "/", true, true);
server1.addServletPackage("/*", this.getClass().getPackage().getName());
server1.waitedStart(5000);
int port2 = port + 1;
- HttpServletServer server2 = HttpServletServer.factory.build("echo-2", LOCALHOST, port2, "/", false, true);
+ HttpServletServer server2 = HttpServletServerFactoryInstance.getServerFactory()
+ .build("echo-2", LOCALHOST, port2, "/", false, true);
server2.addServletPackage("/*", this.getClass().getPackage().getName());
server2.waitedStart(5000);
- assertTrue(HttpServletServer.factory.get(port).isAlive());
- assertTrue(HttpServletServer.factory.get(port2).isAlive());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port2).isAlive());
String response = http(portUrl + JUNIT_ECHO_HELLO);
assertTrue(HELLO.equals(response));
@@ -312,8 +323,8 @@ public class HttpServerTest {
assertThatThrownBy(() -> http(LOCALHOST_PREFIX + port2 + SWAGGER_JSON)).isInstanceOf(IOException.class);
- HttpServletServer.factory.destroy();
- assertTrue(HttpServletServer.factory.inventory().isEmpty());
+ HttpServletServerFactoryInstance.getServerFactory().destroy();
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().inventory().isEmpty());
}
@Test
@@ -322,11 +333,12 @@ public class HttpServerTest {
String randomName = UUID.randomUUID().toString();
- HttpServletServer server = HttpServletServer.factory.build(randomName, LOCALHOST, port, "/", false, true);
+ HttpServletServer server = HttpServletServerFactoryInstance.getServerFactory()
+ .build(randomName, LOCALHOST, port, "/", false, true);
server.addServletPackage("/*", this.getClass().getPackage().getName());
server.waitedStart(5000);
- assertTrue(HttpServletServer.factory.get(port).isAlive());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
String response = http(portUrl + JUNIT_ECHO_HELLO);
assertTrue(HELLO.equals(response));
@@ -334,8 +346,8 @@ public class HttpServerTest {
response = http(portUrl + "/junit/endpoints/http/servers");
assertTrue(response.contains(randomName));
- HttpServletServer.factory.destroy();
- assertTrue(HttpServletServer.factory.inventory().isEmpty());
+ HttpServletServerFactoryInstance.getServerFactory().destroy();
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().inventory().isEmpty());
}
@Test
@@ -343,17 +355,18 @@ public class HttpServerTest {
logger.info("-- testServiceClass() --");
String randomName = UUID.randomUUID().toString();
- HttpServletServer server = HttpServletServer.factory.build(randomName, LOCALHOST, port, "/", false, true);
+ HttpServletServer server = HttpServletServerFactoryInstance.getServerFactory()
+ .build(randomName, LOCALHOST, port, "/", false, true);
server.addServletClass("/*", RestEchoService.class.getName());
server.waitedStart(5000);
- assertTrue(HttpServletServer.factory.get(port).isAlive());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
String response = http(portUrl + JUNIT_ECHO_HELLO);
assertTrue(HELLO.equals(response));
- HttpServletServer.factory.destroy();
- assertTrue(HttpServletServer.factory.inventory().isEmpty());
+ HttpServletServerFactoryInstance.getServerFactory().destroy();
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().inventory().isEmpty());
}
@Test
@@ -362,12 +375,13 @@ public class HttpServerTest {
String randomName = UUID.randomUUID().toString();
- HttpServletServer server = HttpServletServer.factory.build(randomName, LOCALHOST, port, "/", false, true);
+ HttpServletServer server = HttpServletServerFactoryInstance.getServerFactory()
+ .build(randomName, LOCALHOST, port, "/", false, true);
server.addServletClass("/*", RestEchoService.class.getName());
server.addServletClass("/*", RestEndpoints.class.getName());
server.waitedStart(5000);
- assertTrue(HttpServletServer.factory.get(port).isAlive());
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
String response = http(portUrl + JUNIT_ECHO_HELLO);
assertTrue(HELLO.equals(response));
@@ -375,8 +389,8 @@ public class HttpServerTest {
response = http(portUrl + "/junit/endpoints/http/servers");
assertTrue(response.contains(randomName));
- HttpServletServer.factory.destroy();
- assertTrue(HttpServletServer.factory.inventory().isEmpty());
+ HttpServletServerFactoryInstance.getServerFactory().destroy();
+ assertTrue(HttpServletServerFactoryInstance.getServerFactory().inventory().isEmpty());
}
/**
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEndpoints.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEndpoints.java
index fe199645..6ada15c5 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEndpoints.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEndpoints.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-endpoints
* ================================================================================
- * 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.
@@ -28,23 +28,23 @@ import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.onap.policy.common.endpoints.http.server.HttpServletServer;
+import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
@Path("/junit/endpoints")
public class RestEndpoints {
/**
* Returns the http servers.
- *
+ *
* @return the list of servers as a string
*/
@GET
@Path("http/servers")
@Produces(MediaType.TEXT_PLAIN)
- public String httpServers() {
- List<HttpServletServer> servers =
- HttpServletServer.factory.inventory();
+ public String httpServers() {
+ List<HttpServletServer> servers = HttpServletServerFactoryInstance.getServerFactory().inventory();
return servers.toString();
}
-
-
+
+
}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/CommonTestData.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/CommonTestData.java
index 80d1e865..346ac5d6 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/CommonTestData.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/CommonTestData.java
@@ -1,6 +1,8 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 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.
@@ -40,7 +42,7 @@ import org.onap.policy.common.utils.coder.StandardCoder;
*/
public class CommonTestData {
- public static final String REST_SERVER_PASSWORD = "zb!XztG34";
+ public static final String REST_SERVER_PASS = "zb!XztG34";
public static final String REST_SERVER_USER = "healthcheck";
public static final int REST_SERVER_PORT = 6969;
public static final String REST_SERVER_HOST = "0.0.0.0";
@@ -50,9 +52,11 @@ public class CommonTestData {
public static final String TOPIC_NAME = "POLICY-PDP-PAP";
public static final String TOPIC_INFRA = "dmaap";
public static final String TOPIC_SERVER = "message-router";
- public static final List<TopicParameters> TOPIC_PARAMS =
+
+ protected static final List<TopicParameters> TOPIC_PARAMS =
Arrays.asList(getTopicParameters(TOPIC_NAME, TOPIC_INFRA, TOPIC_SERVER));
- public static final Coder coder = new StandardCoder();
+
+ protected static final Coder coder = new StandardCoder();
/**
* Create topic parameters for test cases.
@@ -102,7 +106,7 @@ public class CommonTestData {
map.put("host", REST_SERVER_HOST);
map.put("port", REST_SERVER_PORT);
map.put("userName", REST_SERVER_USER);
- map.put("password", REST_SERVER_PASSWORD);
+ map.put("password", REST_SERVER_PASS);
}
return map;
@@ -133,7 +137,6 @@ public class CommonTestData {
*/
public String getParameterGroupAsString(String filePath) throws IOException {
File file = new File(filePath);
- String json = new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8);
- return json;
+ return new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8);
}
}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/RestServerParametersTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/RestServerParametersTest.java
index ca2b3c4c..58bf98b3 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/RestServerParametersTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/RestServerParametersTest.java
@@ -1,6 +1,8 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 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.
@@ -41,7 +43,7 @@ public class RestServerParametersTest {
private static final Coder coder = new StandardCoder();
@Test
- public void test() throws Exception {
+ public void test() {
final RestServerParameters restServerParameters =
testData.toObject(testData.getRestServerParametersMap(false), RestServerParameters.class);
final GroupValidationResult validationResult = restServerParameters.validate();
@@ -49,13 +51,13 @@ public class RestServerParametersTest {
assertEquals(CommonTestData.REST_SERVER_HOST, restServerParameters.getHost());
assertEquals(CommonTestData.REST_SERVER_PORT, restServerParameters.getPort());
assertEquals(CommonTestData.REST_SERVER_USER, restServerParameters.getUserName());
- assertEquals(CommonTestData.REST_SERVER_PASSWORD, restServerParameters.getPassword());
+ assertEquals(CommonTestData.REST_SERVER_PASS, restServerParameters.getPassword());
assertEquals(CommonTestData.REST_SERVER_HTTPS, restServerParameters.isHttps());
assertEquals(CommonTestData.REST_SERVER_AAF, restServerParameters.isAaf());
}
@Test
- public void testValidate() throws Exception {
+ public void testValidate() {
final RestServerParameters restServerParameters =
testData.toObject(testData.getRestServerParametersMap(false), RestServerParameters.class);
final GroupValidationResult result = restServerParameters.validate();
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/TopicParameterGroupTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/TopicParameterGroupTest.java
index eaf0b2a9..db26a1a4 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/TopicParameterGroupTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/TopicParameterGroupTest.java
@@ -1,6 +1,8 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 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.
@@ -40,7 +42,7 @@ public class TopicParameterGroupTest {
private static final Coder coder = new StandardCoder();
@Test
- public void test() throws Exception {
+ public void test() {
final TopicParameterGroup topicParameterGroup =
testData.toObject(testData.getTopicParameterGroupMap(false), TopicParameterGroup.class);
final GroupValidationResult validationResult = topicParameterGroup.validate();
@@ -50,7 +52,7 @@ public class TopicParameterGroupTest {
}
@Test
- public void testValidate() throws Exception {
+ public void testValidate() {
final TopicParameterGroup topicParameterGroup =
testData.toObject(testData.getTopicParameterGroupMap(false), TopicParameterGroup.class);
final GroupValidationResult result = topicParameterGroup.validate();
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/NetLoggerUtilTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/NetLoggerUtilTest.java
index 2860377e..1e8c0316 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/NetLoggerUtilTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/NetLoggerUtilTest.java
@@ -31,6 +31,7 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.features.NetLoggerFeatureApi;
+import org.onap.policy.common.endpoints.features.NetLoggerFeatureProviders;
import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
import org.slf4j.Logger;
@@ -51,7 +52,7 @@ public class NetLoggerUtilTest {
*/
@BeforeClass
public static void setUp() {
- netLoggerFeature = (NetLoggerFeature) NetLoggerFeatureApi.providers.getList().get(0);
+ netLoggerFeature = (NetLoggerFeature) NetLoggerFeatureProviders.getProviders().getList().get(0);
}
/**
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/ParameterUtilsTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/ParameterUtilsTest.java
index 7e5c3a12..06c16e9c 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/ParameterUtilsTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/ParameterUtilsTest.java
@@ -1,6 +1,8 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 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.
@@ -34,6 +36,7 @@ import org.onap.policy.common.endpoints.parameters.TopicParameterGroup;
* @author Ajith Sreekumar (ajith.sreekumar@est.tech)
*/
public class ParameterUtilsTest {
+ private static final String SERVERS = ".servers";
/**
* Test getTopicProperties from TopicParameterGroup.
@@ -49,9 +52,9 @@ public class ParameterUtilsTest {
assertEquals(CommonTestData.TOPIC_NAME,
topicProperties.getProperty(CommonTestData.TOPIC_INFRA + ".sink.topics"));
assertEquals(CommonTestData.TOPIC_SERVER, topicProperties
- .getProperty(CommonTestData.TOPIC_INFRA + ".source.topics." + CommonTestData.TOPIC_NAME + ".servers"));
+ .getProperty(CommonTestData.TOPIC_INFRA + ".source.topics." + CommonTestData.TOPIC_NAME + SERVERS));
assertEquals(CommonTestData.TOPIC_SERVER, topicProperties
- .getProperty(CommonTestData.TOPIC_INFRA + ".sink.topics." + CommonTestData.TOPIC_NAME + ".servers"));
+ .getProperty(CommonTestData.TOPIC_INFRA + ".sink.topics." + CommonTestData.TOPIC_NAME + SERVERS));
}
@Test
@@ -62,12 +65,12 @@ public class ParameterUtilsTest {
assertEquals(CommonTestData.TOPIC_NAME,
topicProperties.getProperty(CommonTestData.TOPIC_INFRA + ".source.topics"));
assertEquals(CommonTestData.TOPIC_SERVER, topicProperties
- .getProperty(CommonTestData.TOPIC_INFRA + ".source.topics." + CommonTestData.TOPIC_NAME + ".servers"));
+ .getProperty(CommonTestData.TOPIC_INFRA + ".source.topics." + CommonTestData.TOPIC_NAME + SERVERS));
ParameterUtils.updateTopicProperties(topicProperties, "sink", CommonTestData.TOPIC_INFRA,
CommonTestData.TOPIC_NAME, Arrays.asList(CommonTestData.TOPIC_SERVER));
assertEquals(CommonTestData.TOPIC_NAME,
topicProperties.getProperty(CommonTestData.TOPIC_INFRA + ".sink.topics"));
assertEquals(CommonTestData.TOPIC_SERVER, topicProperties
- .getProperty(CommonTestData.TOPIC_INFRA + ".sink.topics." + CommonTestData.TOPIC_NAME + ".servers"));
+ .getProperty(CommonTestData.TOPIC_INFRA + ".sink.topics." + CommonTestData.TOPIC_NAME + SERVERS));
}
}
diff --git a/utils/src/main/java/org/onap/policy/common/utils/network/NetworkUtil.java b/utils/src/main/java/org/onap/policy/common/utils/network/NetworkUtil.java
index 6014b581..14362627 100644
--- a/utils/src/main/java/org/onap/policy/common/utils/network/NetworkUtil.java
+++ b/utils/src/main/java/org/onap/policy/common/utils/network/NetworkUtil.java
@@ -42,7 +42,7 @@ public class NetworkUtil {
/**
* IPv4 Wildcard IP address.
*/
- public static final String IPv4_WILDCARD_ADDRESS = "0.0.0.0";
+ public static final String IPV4_WILDCARD_ADDRESS = "0.0.0.0";
/**
diff --git a/utils/src/test/java/org/onap/policy/common/utils/network/NetworkUtilTest.java b/utils/src/test/java/org/onap/policy/common/utils/network/NetworkUtilTest.java
index c29da2c7..a0b8353d 100644
--- a/utils/src/test/java/org/onap/policy/common/utils/network/NetworkUtilTest.java
+++ b/utils/src/test/java/org/onap/policy/common/utils/network/NetworkUtilTest.java
@@ -42,7 +42,7 @@ public class NetworkUtilTest {
@Test
public void test() throws InterruptedException, IOException {
- assertNotNull(NetworkUtil.IPv4_WILDCARD_ADDRESS);
+ assertNotNull(NetworkUtil.IPV4_WILDCARD_ADDRESS);
assertFalse(NetworkUtil.isTcpPortOpen(LOCALHOST, NetworkUtil.allocPort(), 1, 5));
assertNotNull(NetworkUtil.getHostname());
assertNotNull(NetworkUtil.getHostIp());