From dba5999ebf16a85a996f1f5502c2c154ac3f38b2 Mon Sep 17 00:00:00 2001 From: "waqas.ikram" Date: Fri, 6 Jul 2018 16:37:36 +0100 Subject: Fixing Multi JVM Tests and sonar bugs Change-Id: I02df58695b44d5768410a0eaccb090cda7eb85ba Issue-ID: POLICY-865 Signed-off-by: waqas.ikram --- .../test/locking/TestConcurrentContext.java | 11 +++- .../src/test/resources/hazelcast/hazelcast.xml | 13 +++- .../src/test/resources/logback-test.xml | 76 ---------------------- .../uservice/test/adapt/kafka/TestKafka2Kafka.java | 12 +++- 4 files changed, 29 insertions(+), 83 deletions(-) delete mode 100644 testsuites/integration/integration-context-test/src/test/resources/logback-test.xml (limited to 'testsuites/integration') diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/locking/TestConcurrentContext.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/locking/TestConcurrentContext.java index 7a3a29cc1..e2c2de97a 100644 --- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/locking/TestConcurrentContext.java +++ b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/plugins/context/test/locking/TestConcurrentContext.java @@ -48,6 +48,7 @@ import org.onap.policy.apex.context.test.locking.ConcurrentContext; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; import org.onap.policy.apex.model.basicmodel.handling.ApexModelException; import org.onap.policy.apex.model.basicmodel.service.ParameterService; +import org.onap.policy.apex.model.utilities.ResourceUtils; import org.onap.policy.apex.plugins.context.distribution.hazelcast.HazelcastContextDistributor; import org.onap.policy.apex.plugins.context.distribution.infinispan.InfinispanContextDistributor; import org.onap.policy.apex.plugins.context.distribution.infinispan.InfinispanDistributorParameters; @@ -65,6 +66,11 @@ import com.hazelcast.config.Config; * @author Liam Fallon (liam.fallon@ericsson.com) */ public class TestConcurrentContext { + private static final String HAZELCAST_CONFIG = "hazelcast.config"; + + private static final String JAVA_NET_PREFER_IPV4_STACK = "java.net.preferIPv4Stack"; + private static final String HAZELCAST_XML_FILE = "src/test/resources/hazelcast/hazelcast.xml"; + // Logger for this class private static final XLogger logger = XLoggerFactory.getXLogger(TestConcurrentContext.class); @@ -89,8 +95,9 @@ public class TestConcurrentContext { @BeforeClass public static void configure() throws Exception { - System.setProperty("java.net.preferIPv4Stack", "true"); - System.setProperty("hazelcast.config", "src/test/resources/hazelcast/hazelcast.xml"); + System.setProperty(JAVA_NET_PREFER_IPV4_STACK, "true"); + final String hazelCastfileLocation = ResourceUtils.getFilePath4Resource(HAZELCAST_XML_FILE); + System.setProperty(HAZELCAST_CONFIG, hazelCastfileLocation); // The JGroups IP address must be set to a real (not loopback) IP address for Infinispan to // work. IN order to ensure that all diff --git a/testsuites/integration/integration-context-test/src/test/resources/hazelcast/hazelcast.xml b/testsuites/integration/integration-context-test/src/test/resources/hazelcast/hazelcast.xml index d69f24b90..2918909c3 100644 --- a/testsuites/integration/integration-context-test/src/test/resources/hazelcast/hazelcast.xml +++ b/testsuites/integration/integration-context-test/src/test/resources/hazelcast/hazelcast.xml @@ -41,14 +41,23 @@ - true + false slf4j false 60 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 16 + 2 diff --git a/testsuites/integration/integration-context-test/src/test/resources/logback-test.xml b/testsuites/integration/integration-context-test/src/test/resources/logback-test.xml deleted file mode 100644 index 7fd818d4b..000000000 --- a/testsuites/integration/integration-context-test/src/test/resources/logback-test.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - Apex - - - - - - - %d %contextName [%t] %level %logger{36} - %msg%n - - - - - - - - - ${LOG_DIR}/apex.log - - %d %-5relative [procId=${processId}] [%thread] %-5level - %logger{26} - %msg %n %ex{full} - - - - - ${LOG_DIR}/apex_ctxt.log - - %d %-5relative [procId=${processId}] [%thread] %-5level - %logger{26} - %msg %n %ex{full} - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/kafka/TestKafka2Kafka.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/kafka/TestKafka2Kafka.java index 0874d9827..8468b6d7f 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/kafka/TestKafka2Kafka.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/kafka/TestKafka2Kafka.java @@ -91,9 +91,15 @@ public class TestKafka2Kafka { @AfterClass public static void shutdownDummyKafkaServer() throws IOException { - kafkaServer.shutdown(); - zkClient.close(); - zkServer.shutdown(); + if (kafkaServer != null) { + kafkaServer.shutdown(); + } + if (zkClient != null) { + zkClient.close(); + } + if (zkServer != null) { + zkServer.shutdown(); + } } @Test -- cgit 1.2.3-korg