Merge "Added STD sim 2.0.0 tests"
[nonrtric.git] / policy-agent / src / test / java / org / oransc / policyagent / ApplicationTest.java
index 1a73fbb..4de5c71 100644 (file)
@@ -359,11 +359,12 @@ class ApplicationTest {
 
     @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");
 
@@ -596,7 +597,7 @@ class ApplicationTest {
         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)
@@ -614,7 +615,7 @@ class ApplicationTest {
         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);
@@ -643,8 +644,8 @@ class ApplicationTest {
         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
@@ -720,24 +721,34 @@ class ApplicationTest {
         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()) //