aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/test')
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java59
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionStatistics.java70
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsDistributionRestServer.java61
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsStatisticDistributionRestServer.java64
4 files changed, 132 insertions, 122 deletions
diff --git a/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java b/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java
index d02139f2..356a5861 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +23,9 @@ package org.onap.policy.distribution.main.rest;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
@@ -33,12 +37,13 @@ import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
import org.junit.Test;
import org.onap.policy.common.endpoints.report.HealthCheckReport;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
+import org.onap.policy.common.utils.network.NetworkUtil;
import org.onap.policy.distribution.main.PolicyDistributionException;
import org.onap.policy.distribution.main.parameters.CommonTestData;
import org.onap.policy.distribution.main.parameters.RestServerParameters;
import org.onap.policy.distribution.main.startstop.Main;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Class to perform unit test of HealthCheckMonitor.
@@ -47,33 +52,43 @@ import org.onap.policy.distribution.main.startstop.Main;
*/
public class TestDistributionRestServer {
- private static final Logger LOGGER = FlexLogger.getLogger(TestDistributionRestServer.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(TestDistributionRestServer.class);
private static final String NOT_ALIVE = "not alive";
private static final String ALIVE = "alive";
private static final String SELF = "self";
private static final String NAME = "Policy SSD";
@Test
- public void testHealthCheckSuccess() throws PolicyDistributionException, InterruptedException {
+ public void testHealthCheckSuccess() {
final String reportString = "Report [name=Policy SSD, url=self, healthy=true, code=200, message=alive]";
- final Main main = startDistributionService();
- final HealthCheckReport report = performHealthCheck();
- validateReport(NAME, SELF, true, 200, ALIVE, reportString, report);
- stopDistributionService(main);
+ try {
+ final Main main = startDistributionService();
+ final HealthCheckReport report = performHealthCheck();
+ validateReport(NAME, SELF, true, 200, ALIVE, reportString, report);
+ stopDistributionService(main);
+ } catch (final Exception exp) {
+ LOGGER.error("testHealthCheckSuccess failed", exp);
+ fail("Test should not throw an exception");
+ }
}
@Test
- public void testHealthCheckFailure() throws InterruptedException {
+ public void testHealthCheckFailure() {
final String reportString = "Report [name=Policy SSD, url=self, healthy=false, code=500, message=not alive]";
final RestServerParameters restServerParams = new CommonTestData().getRestServerParameters(false);
restServerParams.setName(CommonTestData.DISTRIBUTION_GROUP_NAME);
final DistributionRestServer restServer = new DistributionRestServer(restServerParams);
- restServer.start();
- final HealthCheckReport report = performHealthCheck();
- validateReport(NAME, SELF, false, 500, NOT_ALIVE, reportString, report);
- assertTrue(restServer.isAlive());
- assertTrue(restServer.toString().startsWith("DistributionRestServer [servers="));
- restServer.shutdown();
+ try {
+ restServer.start();
+ final HealthCheckReport report = performHealthCheck();
+ validateReport(NAME, SELF, false, 500, NOT_ALIVE, reportString, report);
+ assertTrue(restServer.isAlive());
+ assertTrue(restServer.toString().startsWith("DistributionRestServer [servers="));
+ restServer.shutdown();
+ } catch (final Exception exp) {
+ LOGGER.error("testHealthCheckFailure failed", exp);
+ fail("Test should not throw an exception");
+ }
}
private Main startDistributionService() {
@@ -85,8 +100,7 @@ public class TestDistributionRestServer {
main.shutdown();
}
- private HealthCheckReport performHealthCheck() throws InterruptedException {
- HealthCheckReport response = null;
+ private HealthCheckReport performHealthCheck() throws InterruptedException, IOException {
final ClientConfig clientConfig = new ClientConfig();
final HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic("healthcheck", "zb!XztG34");
@@ -96,14 +110,11 @@ public class TestDistributionRestServer {
final WebTarget webTarget = client.target("http://localhost:6969/healthcheck");
final Invocation.Builder invocationBuilder = webTarget.request(MediaType.APPLICATION_JSON);
- while (response == null) {
- try {
- response = invocationBuilder.get(HealthCheckReport.class);
- } catch (final Exception exp) {
- LOGGER.info("the server is not started yet. We will retry again");
- }
+
+ if (!NetworkUtil.isTcpPortOpen("localhost", 6969, 6, 10000L)) {
+ throw new IllegalStateException("cannot connect to port 6969");
}
- return response;
+ return invocationBuilder.get(HealthCheckReport.class);
}
private void validateReport(final String name, final String url, final boolean healthy, final int code,
diff --git a/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionStatistics.java b/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionStatistics.java
index 92ae14a8..6c95a2a8 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionStatistics.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionStatistics.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +22,9 @@
package org.onap.policy.distribution.main.rest;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
@@ -31,13 +35,14 @@ import javax.ws.rs.core.MediaType;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
import org.junit.Test;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
+import org.onap.policy.common.utils.network.NetworkUtil;
import org.onap.policy.distribution.main.PolicyDistributionException;
import org.onap.policy.distribution.main.parameters.CommonTestData;
import org.onap.policy.distribution.main.parameters.RestServerParameters;
import org.onap.policy.distribution.main.startstop.Main;
import org.onap.policy.distribution.reception.statistics.DistributionStatisticsManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Class to perform unit test of {@link DistributionRestController}.
@@ -46,40 +51,45 @@ import org.onap.policy.distribution.reception.statistics.DistributionStatisticsM
*/
public class TestDistributionStatistics {
- private static final Logger LOGGER = FlexLogger.getLogger(TestDistributionStatistics.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(TestDistributionStatistics.class);
@Test
- public void testDistributionStatistics_200() throws PolicyDistributionException, InterruptedException {
- final Main main = startDistributionService();
- StatisticsReport report = getDistributionStatistics();
-
- validateReport(report, 0, 200);
- updateDistributionStatistics();
- report = getDistributionStatistics();
- validateReport(report, 1, 200);
- stopDistributionService(main);
- DistributionStatisticsManager.resetAllStatistics();
+ public void testDistributionStatistics_200() {
+ try {
+ final Main main = startDistributionService();
+ StatisticsReport report = getDistributionStatistics();
+ validateReport(report, 0, 200);
+ updateDistributionStatistics();
+ report = getDistributionStatistics();
+ validateReport(report, 1, 200);
+ stopDistributionService(main);
+ DistributionStatisticsManager.resetAllStatistics();
+ } catch (final Exception exp) {
+ LOGGER.error("testDistributionStatistics_200 failed", exp);
+ fail("Test should not throw an exception");
+ }
}
@Test
public void testDistributionStatistics_500() throws InterruptedException {
final RestServerParameters restServerParams = new CommonTestData().getRestServerParameters(false);
restServerParams.setName(CommonTestData.DISTRIBUTION_GROUP_NAME);
-
final DistributionRestServer restServer = new DistributionRestServer(restServerParams);
- restServer.start();
- final StatisticsReport report = getDistributionStatistics();
-
- validateReport(report, 0, 500);
- restServer.shutdown();
- DistributionStatisticsManager.resetAllStatistics();
+ try {
+ restServer.start();
+ final StatisticsReport report = getDistributionStatistics();
+ validateReport(report, 0, 500);
+ restServer.shutdown();
+ DistributionStatisticsManager.resetAllStatistics();
+ } catch (final Exception exp) {
+ LOGGER.error("testDistributionStatistics_500 failed", exp);
+ fail("Test should not throw an exception");
+ }
}
-
private Main startDistributionService() {
- final String[] distributionConfigParameters =
- { "-c", "parameters/DistributionConfigParameters.json" };
+ final String[] distributionConfigParameters = { "-c", "parameters/DistributionConfigParameters.json" };
return new Main(distributionConfigParameters);
}
@@ -87,8 +97,7 @@ public class TestDistributionStatistics {
main.shutdown();
}
- private StatisticsReport getDistributionStatistics() throws InterruptedException {
- StatisticsReport response = null;
+ private StatisticsReport getDistributionStatistics() throws InterruptedException, IOException {
final ClientConfig clientConfig = new ClientConfig();
final HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic("healthcheck", "zb!XztG34");
@@ -98,14 +107,11 @@ public class TestDistributionStatistics {
final WebTarget webTarget = client.target("http://localhost:6969/statistics");
final Invocation.Builder invocationBuilder = webTarget.request(MediaType.APPLICATION_JSON);
- while (response == null) {
- try {
- response = invocationBuilder.get(StatisticsReport.class);
- } catch (final Exception exp) {
- LOGGER.info("the server is not started yet. We will retry again");
- }
+
+ if (!NetworkUtil.isTcpPortOpen("localhost", 6969, 6, 10000L)) {
+ throw new IllegalStateException("cannot connect to port 6969");
}
- return response;
+ return invocationBuilder.get(StatisticsReport.class);
}
private void updateDistributionStatistics() {
diff --git a/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsDistributionRestServer.java b/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsDistributionRestServer.java
index 6667d7fd..f3046c29 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsDistributionRestServer.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsDistributionRestServer.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Intel. All rights reserved.
+ * Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,9 +22,8 @@
package org.onap.policy.distribution.main.rest;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
-import java.security.KeyManagementException;
-import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.cert.X509Certificate;
import java.util.Properties;
@@ -31,7 +31,6 @@ import java.util.Properties;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
-
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Invocation;
@@ -41,10 +40,11 @@ import javax.ws.rs.core.MediaType;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
import org.junit.Test;
import org.onap.policy.common.endpoints.report.HealthCheckReport;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
+import org.onap.policy.common.utils.network.NetworkUtil;
import org.onap.policy.distribution.main.PolicyDistributionException;
import org.onap.policy.distribution.main.startstop.Main;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Class to perform unit test of HealthCheckMonitor.
@@ -53,24 +53,28 @@ import org.onap.policy.distribution.main.startstop.Main;
*/
public class TestHttpsDistributionRestServer {
- private static final Logger LOGGER = FlexLogger.getLogger(TestDistributionRestServer.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(TestHttpsDistributionRestServer.class);
private static final String ALIVE = "alive";
private static final String SELF = "self";
private static final String NAME = "Policy SSD";
private static String KEYSTORE = System.getProperty("user.dir") + "/src/test/resources/ssl/policy-keystore";
@Test
- public void testHealthCheckSuccess()
- throws PolicyDistributionException, InterruptedException, KeyManagementException, NoSuchAlgorithmException {
+ public void testHttpsHealthCheckSuccess() {
final String reportString = "Report [name=Policy SSD, url=self, healthy=true, code=200, message=alive]";
- final Main main = startDistributionService();
- final HealthCheckReport report = performHealthCheck();
- validateReport(NAME, SELF, true, 200, ALIVE, reportString, report);
- stopDistributionService(main);
+ try {
+ final Main main = startDistributionService();
+ final HealthCheckReport report = performHealthCheck();
+ validateReport(NAME, SELF, true, 200, ALIVE, reportString, report);
+ stopDistributionService(main);
+ } catch (final Exception exp) {
+ LOGGER.error("testHttpsHealthCheckSuccess failed", exp);
+ fail("Test should not throw an exception");
+ }
}
private Main startDistributionService() {
- Properties systemProps = System.getProperties();
+ final Properties systemProps = System.getProperties();
systemProps.put("javax.net.ssl.keyStore", KEYSTORE);
systemProps.put("javax.net.ssl.keyStorePassword", "Pol1cy_0nap");
System.setProperties(systemProps);
@@ -83,11 +87,9 @@ public class TestHttpsDistributionRestServer {
main.shutdown();
}
- private HealthCheckReport performHealthCheck()
- throws InterruptedException, KeyManagementException, NoSuchAlgorithmException {
- HealthCheckReport response = null;
+ private HealthCheckReport performHealthCheck() throws Exception {
- TrustManager[] noopTrustManager = new TrustManager[] { new X509TrustManager() {
+ final TrustManager[] noopTrustManager = new TrustManager[] { new X509TrustManager() {
@Override
public X509Certificate[] getAcceptedIssuers() {
@@ -95,18 +97,16 @@ public class TestHttpsDistributionRestServer {
}
@Override
- public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {
- }
+ public void checkClientTrusted(final java.security.cert.X509Certificate[] certs, final String authType) {}
@Override
- public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {
- }
+ public void checkServerTrusted(final java.security.cert.X509Certificate[] certs, final String authType) {}
} };
- SSLContext sc = SSLContext.getInstance("TLSv1.2");
+ final SSLContext sc = SSLContext.getInstance("TLSv1.2");
sc.init(null, noopTrustManager, new SecureRandom());
- final ClientBuilder clientBuilder = ClientBuilder.newBuilder().sslContext(sc)
- .hostnameVerifier((host, session) -> true);
+ final ClientBuilder clientBuilder =
+ ClientBuilder.newBuilder().sslContext(sc).hostnameVerifier((host, session) -> true);
final Client client = clientBuilder.build();
final HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic("healthcheck", "zb!XztG34");
client.register(feature);
@@ -114,18 +114,15 @@ public class TestHttpsDistributionRestServer {
final WebTarget webTarget = client.target("https://localhost:6969/healthcheck");
final Invocation.Builder invocationBuilder = webTarget.request(MediaType.APPLICATION_JSON);
- while (response == null) {
- try {
- response = invocationBuilder.get(HealthCheckReport.class);
- } catch (final Exception exp) {
- LOGGER.error("the server is not started yet. We will retry again", exp);
- }
+
+ if (!NetworkUtil.isTcpPortOpen("localhost", 6969, 6, 10000L)) {
+ throw new IllegalStateException("cannot connect to port 6969");
}
- return response;
+ return invocationBuilder.get(HealthCheckReport.class);
}
private void validateReport(final String name, final String url, final boolean healthy, final int code,
- final String message, final String reportString, final HealthCheckReport report) {
+ final String message, final String reportString, final HealthCheckReport report) {
assertEquals(name, report.getName());
assertEquals(url, report.getUrl());
assertEquals(healthy, report.isHealthy());
diff --git a/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsStatisticDistributionRestServer.java b/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsStatisticDistributionRestServer.java
index 5aadb6ed..ba64e550 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsStatisticDistributionRestServer.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsStatisticDistributionRestServer.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Intel. All rights reserved.
+ * Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +22,7 @@
package org.onap.policy.distribution.main.rest;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
@@ -31,7 +33,6 @@ import java.util.Properties;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
-
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Invocation;
@@ -40,10 +41,11 @@ import javax.ws.rs.core.MediaType;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
import org.junit.Test;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
+import org.onap.policy.common.utils.network.NetworkUtil;
import org.onap.policy.distribution.main.PolicyDistributionException;
import org.onap.policy.distribution.main.startstop.Main;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Class to perform unit test of HealthCheckMonitor.
@@ -52,22 +54,25 @@ import org.onap.policy.distribution.main.startstop.Main;
*/
public class TestHttpsStatisticDistributionRestServer {
- private static final Logger LOGGER = FlexLogger.getLogger(TestHttpsStatisticDistributionRestServer.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(TestHttpsStatisticDistributionRestServer.class);
private static String KEYSTORE = System.getProperty("user.dir") + "/src/test/resources/ssl/policy-keystore";
@Test
- public void testDistributionStatistic()
- throws PolicyDistributionException, InterruptedException, KeyManagementException, NoSuchAlgorithmException {
- final String reportString = "StatisticsReport [code=200, totalDistributionCount=0, distributionSuccessCount=0, "
- + "distributionFailureCount=0, totalDownloadCount=0, " + "downloadSuccessCount=0, downloadFailureCount=0]";
- final Main main = startDistributionService();
- final StatisticsReport report = performStatisticCheck();
- validateReport(200, 0, 0, 0, 0, 0, 0, reportString, report);
- stopDistributionService(main);
+ public void testHttpsDistributionStatistic()
+ throws PolicyDistributionException, InterruptedException, KeyManagementException, NoSuchAlgorithmException {
+ try {
+ final Main main = startDistributionService();
+ final StatisticsReport report = performStatisticCheck();
+ validateReport(200, 0, 0, 0, 0, 0, 0, report);
+ stopDistributionService(main);
+ } catch (final Exception exp) {
+ LOGGER.error("testHttpsDistributionStatistic failed", exp);
+ fail("Test should not throw an exception");
+ }
}
private Main startDistributionService() {
- Properties systemProps = System.getProperties();
+ final Properties systemProps = System.getProperties();
systemProps.put("javax.net.ssl.keyStore", KEYSTORE);
systemProps.put("javax.net.ssl.keyStorePassword", "Pol1cy_0nap");
System.setProperties(systemProps);
@@ -80,11 +85,9 @@ public class TestHttpsStatisticDistributionRestServer {
main.shutdown();
}
- private StatisticsReport performStatisticCheck()
- throws InterruptedException, KeyManagementException, NoSuchAlgorithmException {
- StatisticsReport response = null;
+ private StatisticsReport performStatisticCheck() throws Exception {
- TrustManager[] noopTrustManager = new TrustManager[] { new X509TrustManager() {
+ final TrustManager[] noopTrustManager = new TrustManager[] { new X509TrustManager() {
@Override
public X509Certificate[] getAcceptedIssuers() {
@@ -92,18 +95,16 @@ public class TestHttpsStatisticDistributionRestServer {
}
@Override
- public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {
- }
+ public void checkClientTrusted(final java.security.cert.X509Certificate[] certs, final String authType) {}
@Override
- public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {
- }
+ public void checkServerTrusted(final java.security.cert.X509Certificate[] certs, final String authType) {}
} };
- SSLContext sc = SSLContext.getInstance("TLSv1.2");
+ final SSLContext sc = SSLContext.getInstance("TLSv1.2");
sc.init(null, noopTrustManager, new SecureRandom());
- final ClientBuilder clientBuilder = ClientBuilder.newBuilder().sslContext(sc)
- .hostnameVerifier((host, session) -> true);
+ final ClientBuilder clientBuilder =
+ ClientBuilder.newBuilder().sslContext(sc).hostnameVerifier((host, session) -> true);
final Client client = clientBuilder.build();
final HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic("healthcheck", "zb!XztG34");
client.register(feature);
@@ -111,19 +112,15 @@ public class TestHttpsStatisticDistributionRestServer {
final WebTarget webTarget = client.target("https://localhost:6969/statistics");
final Invocation.Builder invocationBuilder = webTarget.request(MediaType.APPLICATION_JSON);
- while (response == null) {
- try {
- response = invocationBuilder.get(StatisticsReport.class);
- } catch (final Exception exp) {
- LOGGER.error("the server is not started yet. We will retry again", exp);
- }
+
+ if (!NetworkUtil.isTcpPortOpen("localhost", 6969, 6, 10000L)) {
+ throw new IllegalStateException("cannot connect to port 6969");
}
- return response;
+ return invocationBuilder.get(StatisticsReport.class);
}
private void validateReport(final int code, final int total, final int successCount, final int failureCount,
- final int download, final int downloadSuccess, final int downloadFailure, final String reportString,
- final StatisticsReport report) {
+ final int download, final int downloadSuccess, final int downloadFailure, final StatisticsReport report) {
assertEquals(code, report.getCode());
assertEquals(total, report.getTotalDistributionCount());
assertEquals(successCount, report.getDistributionSuccessCount());
@@ -131,6 +128,5 @@ public class TestHttpsStatisticDistributionRestServer {
assertEquals(download, report.getTotalDownloadCount());
assertEquals(downloadSuccess, report.getDownloadSuccessCount());
assertEquals(downloadFailure, report.getDownloadFailureCount());
- assertEquals(reportString, report.toString());
}
}