aboutsummaryrefslogtreecommitdiffstats
path: root/main/src
diff options
context:
space:
mode:
Diffstat (limited to 'main/src')
-rw-r--r--main/src/main/java/org/onap/policy/distribution/main/parameters/DistributionParameterHandler.java2
-rw-r--r--main/src/main/java/org/onap/policy/distribution/main/parameters/PolicyForwarderConfigurationParametersJsonAdapter.java2
-rw-r--r--main/src/main/java/org/onap/policy/distribution/main/startstop/DistributionActivator.java10
-rw-r--r--main/src/main/java/org/onap/policy/distribution/main/startstop/Main.java4
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/startstop/TestMain.java10
-rw-r--r--main/src/test/resources/logback-test.xml41
6 files changed, 59 insertions, 10 deletions
diff --git a/main/src/main/java/org/onap/policy/distribution/main/parameters/DistributionParameterHandler.java b/main/src/main/java/org/onap/policy/distribution/main/parameters/DistributionParameterHandler.java
index 7ef5fd75..f7314220 100644
--- a/main/src/main/java/org/onap/policy/distribution/main/parameters/DistributionParameterHandler.java
+++ b/main/src/main/java/org/onap/policy/distribution/main/parameters/DistributionParameterHandler.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2020 AT&T Inc.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -69,7 +70,6 @@ public class DistributionParameterHandler {
} catch (final Exception e) {
final String errorMessage = "error reading parameters from \"" + arguments.getConfigurationFilePath()
+ "\"\n" + "(" + e.getClass().getSimpleName() + "):" + e.getMessage();
- LOGGER.error(errorMessage, e);
throw new PolicyDistributionException(errorMessage, e);
}
diff --git a/main/src/main/java/org/onap/policy/distribution/main/parameters/PolicyForwarderConfigurationParametersJsonAdapter.java b/main/src/main/java/org/onap/policy/distribution/main/parameters/PolicyForwarderConfigurationParametersJsonAdapter.java
index 687970dc..640353ea 100644
--- a/main/src/main/java/org/onap/policy/distribution/main/parameters/PolicyForwarderConfigurationParametersJsonAdapter.java
+++ b/main/src/main/java/org/onap/policy/distribution/main/parameters/PolicyForwarderConfigurationParametersJsonAdapter.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2020 AT&T Inc.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -74,7 +75,6 @@ public class PolicyForwarderConfigurationParametersJsonAdapter
} catch (final ClassNotFoundException e) {
final String errorMessage = "parameter \"" + PARAMETER_CLASS_NAME + "\" value \""
+ policyForwarderParameterClassName + "\", could not find class";
- LOGGER.warn(errorMessage, e);
throw new IllegalArgumentException(errorMessage, e);
}
return policyForwarderParameterClass;
diff --git a/main/src/main/java/org/onap/policy/distribution/main/startstop/DistributionActivator.java b/main/src/main/java/org/onap/policy/distribution/main/startstop/DistributionActivator.java
index a50fa6bc..3f19baf1 100644
--- a/main/src/main/java/org/onap/policy/distribution/main/startstop/DistributionActivator.java
+++ b/main/src/main/java/org/onap/policy/distribution/main/startstop/DistributionActivator.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@
package org.onap.policy.distribution.main.startstop;
+import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
@@ -82,12 +83,14 @@ public class DistributionActivator {
try {
final Class<AbstractReceptionHandler> receptionHandlerClass = (Class<AbstractReceptionHandler>) Class
.forName(receptionHandlerParameters.getReceptionHandlerClassName());
- final AbstractReceptionHandler receptionHandler = receptionHandlerClass.newInstance();
+ final AbstractReceptionHandler receptionHandler =
+ receptionHandlerClass.getDeclaredConstructor().newInstance();
receptionHandler.initialize(receptionHandlerParameters.getName());
receptionHandlersMap.put(receptionHandlerParameters.getName(), receptionHandler);
DistributionActivator.setAlive(true);
} catch (final ClassNotFoundException | InstantiationException | IllegalAccessException
- | PluginInitializationException exp) {
+ | PluginInitializationException | IllegalArgumentException | InvocationTargetException
+ | NoSuchMethodException | SecurityException exp) {
throw new PolicyDistributionException(exp.getMessage(), exp);
}
}
@@ -126,7 +129,6 @@ public class DistributionActivator {
// Stop the distribution rest server
restServer.stop();
} catch (final Exception exp) {
- LOGGER.error("Policy distribution service termination failed", exp);
throw new PolicyDistributionException(exp.getMessage(), exp);
}
}
diff --git a/main/src/main/java/org/onap/policy/distribution/main/startstop/Main.java b/main/src/main/java/org/onap/policy/distribution/main/startstop/Main.java
index 13da2169..2c676333 100644
--- a/main/src/main/java/org/onap/policy/distribution/main/startstop/Main.java
+++ b/main/src/main/java/org/onap/policy/distribution/main/startstop/Main.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2020 AT&T Inc.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -84,7 +85,8 @@ public class Main {
try {
activator.initialize();
} catch (final PolicyDistributionException e) {
- LOGGER.error("start of policy distribution service failed, used parameters are " + Arrays.toString(args),
+ LOGGER.error("start of policy distribution service failed, used parameters are {}",
+ Arrays.toString(args),
e);
return;
}
diff --git a/main/src/test/java/org/onap/policy/distribution/main/startstop/TestMain.java b/main/src/test/java/org/onap/policy/distribution/main/startstop/TestMain.java
index e1c5d22b..e5d03aaf 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/startstop/TestMain.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/startstop/TestMain.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 AT&T Inc.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,6 +21,7 @@
package org.onap.policy.distribution.main.startstop;
+import static org.assertj.core.api.Assertions.assertThatCode;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -62,9 +64,11 @@ public class TestMain {
@Test
public void testMain_Help() {
- final String[] distributionConfigParameters =
- { "-h" };
- Main.main(distributionConfigParameters);
+ assertThatCode(() -> {
+ final String[] distributionConfigParameters =
+ { "-h" };
+ Main.main(distributionConfigParameters);
+ }).doesNotThrowAnyException();
}
@Test
diff --git a/main/src/test/resources/logback-test.xml b/main/src/test/resources/logback-test.xml
new file mode 100644
index 00000000..f2f8acbb
--- /dev/null
+++ b/main/src/test/resources/logback-test.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2020 AT&T. 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=========================================================
+-->
+
+<configuration>
+
+ <contextName>policy-api</contextName>
+ <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
+
+ <!-- USE FOR STD OUT ONLY -->
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
+ </encoder>
+ </appender>
+
+ <root level="INFO">
+ <appender-ref ref="STDOUT" />
+ </root>
+
+ <logger name="org.eclipse.jetty.server.RequestLog" level="WARN" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
+</configuration>