@Test
/**
- * Test that HttpStatus and body from failing REST call to A1 is passed on to the caller.
+ * Test that HttpStatus and body from failing REST call to A1 is passed on to
+ * the caller.
*
* @throws ServiceException
*/
- void testErrorFromRIC() throws ServiceException {
+ void testErrorFromRic() throws ServiceException {
putService("service1");
addPolicyType("type1", "ric1");
List<ServiceStatus> info = parseList(rsp, ServiceStatus.class);
assertThat(info).hasSize(1);
ServiceStatus status = info.iterator().next();
- assertThat(status.keepAliveIntervalSeconds).isEqualTo(0);
+ assertThat(status.keepAliveIntervalSeconds).isZero();
assertThat(status.serviceName).isEqualTo(serviceName);
// GET (all)
assertThat(services.size()).isEqualTo(1);
url = "/services?name=name";
restClient().delete(url).block();
- assertThat(services.size()).isEqualTo(0);
+ assertThat(services.size()).isZero();
// Keep alive, no registered service
testErrorCode(restClient().put("/services/keepalive?name=name", ""), HttpStatus.NOT_FOUND);
assertThat(services.size()).isEqualTo(1);
// Timeout after ~1 second
- await().untilAsserted(() -> assertThat(policies.size()).isEqualTo(0));
- assertThat(services.size()).isEqualTo(0);
+ await().untilAsserted(() -> assertThat(policies.size()).isZero());
+ assertThat(services.size()).isZero();
}
@Test
addRic("ric");
addPolicyType("type1", "ric");
addPolicyType("type2", "ric");
+ List<ConcurrencyTestRunnable> tests = new ArrayList<>();
for (int i = 0; i < 10; ++i) {
- Thread thread =
- new Thread(new ConcurrencyTestRunnable(baseUrl(), supervision, a1ClientFactory, rics, policyTypes),
- "TestThread_" + i);
+ ConcurrencyTestRunnable test =
+ new ConcurrencyTestRunnable(restClient(), supervision, a1ClientFactory, rics, policyTypes);
+ Thread thread = new Thread(test, "TestThread_" + i);
thread.start();
threads.add(thread);
+ tests.add(test);
}
for (Thread t : threads) {
t.join();
}
- assertThat(policies.size()).isEqualTo(0);
+ for (ConcurrencyTestRunnable test : tests) {
+ assertThat(test.isFailed()).isFalse();
+ }
+
+ assertThat(policies.size()).isZero();
logger.info("Concurrency test took " + Duration.between(startTime, Instant.now()));
}
private AsyncRestClient restClient(boolean useTrustValidation) {
WebClientConfig config = this.applicationConfig.getWebClientConfig();
config = ImmutableWebClientConfig.builder() //
+ .keyStoreType(config.keyStoreType()) //
+ .keyStorePassword(config.keyStorePassword()) //
+ .keyStore(config.keyStore()) //
+ .keyPassword(config.keyPassword()) //
.isTrustStoreUsed(useTrustValidation) //
.trustStore(config.trustStore()) //
.trustStorePassword(config.trustStorePassword()) //