This is an automated email from the ASF dual-hosted git repository.

ilgrosso pushed a commit to branch 3_0_X
in repository https://gitbox.apache.org/repos/asf/syncope.git

commit b020feca324da0b829a4c10af79fd1f54a720fb5
Author: Francesco Chicchiriccò <[email protected]>
AuthorDate: Thu Jun 22 13:17:52 2023 +0200

    Ensure Core is ready before running WA unit tests
---
 wa/starter/pom.xml                                          |  8 ++++----
 .../java/org/apache/syncope/wa/starter/AbstractTest.java    | 13 +++++++++++++
 .../apache/syncope/wa/starter/WAServiceRegistryTest.java    |  4 ----
 3 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/wa/starter/pom.xml b/wa/starter/pom.xml
index 5b2d47f4f1..b7a85f5844 100644
--- a/wa/starter/pom.xml
+++ b/wa/starter/pom.xml
@@ -383,13 +383,13 @@ under the License.
       <scope>test</scope>      
     </dependency>
     <dependency>
-      <groupId>org.springframework.boot</groupId>
-      <artifactId>spring-boot-starter-test</artifactId>
+      <groupId>org.awaitility</groupId>
+      <artifactId>awaitility</artifactId>
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>org.junit.jupiter</groupId>
-      <artifactId>junit-jupiter</artifactId>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter-test</artifactId>
       <scope>test</scope>
     </dependency>
   </dependencies>
diff --git 
a/wa/starter/src/test/java/org/apache/syncope/wa/starter/AbstractTest.java 
b/wa/starter/src/test/java/org/apache/syncope/wa/starter/AbstractTest.java
index 0c37f9e86e..95ac596edd 100644
--- a/wa/starter/src/test/java/org/apache/syncope/wa/starter/AbstractTest.java
+++ b/wa/starter/src/test/java/org/apache/syncope/wa/starter/AbstractTest.java
@@ -18,7 +18,13 @@
  */
 package org.apache.syncope.wa.starter;
 
+import static org.awaitility.Awaitility.await;
+
 import java.util.UUID;
+import java.util.concurrent.TimeUnit;
+import org.apache.syncope.wa.bootstrap.WARestClient;
+import org.junit.jupiter.api.BeforeEach;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.boot.test.context.TestConfiguration;
 import org.springframework.boot.test.web.server.LocalServerPort;
@@ -57,4 +63,11 @@ public abstract class AbstractTest {
     @LocalServerPort
     protected int port;
 
+    @Autowired
+    private WARestClient waRestClient;
+
+    @BeforeEach
+    public void waitForCore() {
+        await().atMost(50, TimeUnit.SECONDS).pollInterval(1, 
TimeUnit.SECONDS).until(() -> waRestClient.isReady());
+    }
 }
diff --git 
a/wa/starter/src/test/java/org/apache/syncope/wa/starter/WAServiceRegistryTest.java
 
b/wa/starter/src/test/java/org/apache/syncope/wa/starter/WAServiceRegistryTest.java
index 88477ebc44..7eaff948e3 100644
--- 
a/wa/starter/src/test/java/org/apache/syncope/wa/starter/WAServiceRegistryTest.java
+++ 
b/wa/starter/src/test/java/org/apache/syncope/wa/starter/WAServiceRegistryTest.java
@@ -151,8 +151,6 @@ public class WAServiceRegistryTest extends AbstractTest {
     @Test
     public void addClientApp() {
         // 1. start with no client apps defined on mocked Core
-        assertTrue(waRestClient.isReady());
-
         SyncopeCoreTestingServer.CLIENT_APPS.clear();
 
         WAClientAppService service = 
waRestClient.getService(WAClientAppService.class);
@@ -230,8 +228,6 @@ public class WAServiceRegistryTest extends AbstractTest {
     @Test
     public void delegatedAuthentication() {
         // 1. start with 1 client app and 1 auth module defined on mocked Core
-        assertTrue(waRestClient.isReady());
-
         OIDCAuthModuleConf oidcAuthModuleConf = new OIDCAuthModuleConf();
         oidcAuthModuleConf.setClientId("clientId");
         oidcAuthModuleConf.setClientSecret("clientSecret");

Reply via email to