import java.io.File;
import java.security.SecureRandom;
-import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.function.Function;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import org.glassfish.jersey.client.ClientProperties;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
+import org.onap.policy.common.gson.GsonMessageBodyHandler;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.network.NetworkUtil;
+import org.onap.policy.common.utils.services.Registry;
+import org.onap.policy.pap.main.PapConstants;
import org.onap.policy.pap.main.PolicyPapException;
+import org.onap.policy.pap.main.parameters.CommonTestData;
import org.onap.policy.pap.main.startstop.Main;
import org.onap.policy.pap.main.startstop.PapActivator;
import org.powermock.reflect.Whitebox;
startMain();
}
- activatorWasAlive = PapActivator.getCurrent().isAlive();
+ activatorWasAlive = Registry.get(PapConstants.REG_PAP_ACTIVATOR, PapActivator.class).isAlive();
}
/**
*/
@After
public void tearDown() {
- Whitebox.setInternalState(PapActivator.getCurrent(), "alive", activatorWasAlive);
+ markActivator(activatorWasAlive);
}
/**
* @throws Exception if an error occurs
*/
private static void makeConfigFile() throws Exception {
- Map<String, Object> restParams = new HashMap<>();
- restParams.put("host", "0.0.0.0");
- restParams.put("port", port);
- restParams.put("userName", "healthcheck");
- restParams.put("password", "zb!XztG34");
- restParams.put("https", true);
-
- Map<String, Object> pdpGroupDeploy = new HashMap<>();
- pdpGroupDeploy.put("waitResponseMs", "0");
+ Map<String, Object> config = new CommonTestData().getPapParameterGroupMap("PapGroup");
- Map<String, Object> config = new HashMap<>();
- config.put("name", "PapGroup");
- config.put("restServerParameters", restParams);
- config.put("pdpGroupDeploymentParameters", pdpGroupDeploy);
+ @SuppressWarnings("unchecked")
+ Map<String, Object> restParams = (Map<String, Object>) config.get("restServerParameters");
+ restParams.put("port", port);
File file = new File("src/test/resources/parameters/TestConfigParams.json");
file.deleteOnExit();
* @throws Exception if an error occurs
*/
private static void startMain() throws Exception {
+ Registry.newRegistry();
+
// make sure port is available
if (NetworkUtil.isTcpPortOpen("localhost", port, 1, 1L)) {
throw new IllegalStateException("port " + port + " is still in use");
* Mark the activator as dead, but leave its REST server running.
*/
protected void markActivatorDead() {
- Whitebox.setInternalState(PapActivator.getCurrent(), "alive", false);
+ markActivator(false);
+ }
+
+ private void markActivator(boolean wasAlive) {
+ Object manager = Whitebox.getInternalState(Registry.get(PapConstants.REG_PAP_ACTIVATOR, PapActivator.class),
+ "serviceManager");
+ Whitebox.setInternalState(manager, "running", wasAlive);
}
/**
ClientBuilder.newBuilder().sslContext(sc).hostnameVerifier((host, session) -> true);
final Client client = clientBuilder.build();
+ client.property(ClientProperties.METAINF_SERVICES_LOOKUP_DISABLE, "true");
+ client.register(GsonMessageBodyHandler.class);
+
if (includeAuth) {
final HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic("healthcheck", "zb!XztG34");
client.register(feature);