package org.onap.policy.pap.main.startstop;
import java.util.Arrays;
+import org.onap.policy.common.utils.resources.MessageConstants;
import org.onap.policy.common.utils.services.Registry;
import org.onap.policy.pap.main.PapConstants;
import org.onap.policy.pap.main.PolicyPapException;
*/
public class Main {
- private static final String START_FAILED = "start of policy pap service failed";
-
private static final Logger LOGGER = LoggerFactory.getLogger(Main.class);
private PapActivator activator;
if (null != activator) {
Registry.unregister(PapConstants.REG_PAP_ACTIVATOR);
}
- throw new PolicyPapRuntimeException(START_FAILED + ", used parameters are " + Arrays.toString(args), exp);
+ throw new PolicyPapRuntimeException(
+ String.format(MessageConstants.START_FAILURE_MSG, MessageConstants.POLICY_PAP), exp);
}
// Add a shutdown hook to shut everything down in an orderly manner
Runtime.getRuntime().addShutdownHook(new PolicyPapShutdownHookClass());
- LOGGER.info("Started policy pap service");
+ String successMsg = String.format(MessageConstants.START_SUCCESS_MSG, MessageConstants.POLICY_PAP);
+ LOGGER.info(successMsg);
}
/**
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
+import org.onap.policy.common.utils.resources.MessageConstants;
import org.onap.policy.common.utils.services.Registry;
import org.onap.policy.pap.main.PapConstants;
import org.onap.policy.pap.main.PolicyPapException;
public void testMain_NoArguments() {
final String[] papConfigParameters = {};
assertThatThrownBy(() -> new Main(papConfigParameters)).isInstanceOf(PolicyPapRuntimeException.class)
- .hasMessage("start of policy pap service failed, used parameters are []");
+ .hasMessage(String.format(MessageConstants.START_FAILURE_MSG, MessageConstants.POLICY_PAP));
}
@Test
public void testMain_InvalidArguments() {
final String[] papConfigParameters = {"parameters/PapConfigParameters.json"};
assertThatThrownBy(() -> new Main(papConfigParameters)).isInstanceOf(PolicyPapRuntimeException.class)
- .hasMessage(
- "start of policy pap service failed, used parameters are [parameters/PapConfigParameters.json]");
+ .hasMessage(String.format(MessageConstants.START_FAILURE_MSG, MessageConstants.POLICY_PAP));
}
@Test
public void testMain_InvalidParameters() {
final String[] papConfigParameters = {"-c", "parameters/PapConfigParameters_InvalidName.json"};
assertThatThrownBy(() -> new Main(papConfigParameters)).isInstanceOf(PolicyPapRuntimeException.class)
- .hasMessage("start of policy pap service failed, "
- + "used parameters are [-c, parameters/PapConfigParameters_InvalidName.json]");
+ .hasMessage(String.format(MessageConstants.START_FAILURE_MSG, MessageConstants.POLICY_PAP));
}
}