From 354c345712a1c9d793e1cd989466f9a403fb5d35 Mon Sep 17 00:00:00 2001 From: Bilal Al Date: Thu, 5 Sep 2024 12:55:16 -0700 Subject: [PATCH] revert timeout to 2s --- .../io/split/client/SplitFactoryImplTest.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/client/src/test/java/io/split/client/SplitFactoryImplTest.java b/client/src/test/java/io/split/client/SplitFactoryImplTest.java index 2aa157b3..4cf9d896 100644 --- a/client/src/test/java/io/split/client/SplitFactoryImplTest.java +++ b/client/src/test/java/io/split/client/SplitFactoryImplTest.java @@ -33,6 +33,7 @@ import java.net.InetSocketAddress; import java.net.Proxy; import java.net.URISyntaxException; + import java.util.HashMap; import java.util.Map; @@ -41,6 +42,10 @@ import okhttp3.logging.HttpLoggingInterceptor; import okhttp3.Interceptor; +import java.util.concurrent.Callable; +import java.util.concurrent.TimeUnit; + +import static org.awaitility.Awaitility.await; import static org.mockito.Mockito.when; @RunWith(PowerMockRunner.class) @@ -217,10 +222,24 @@ public void testFactoryConsumerInstantiationRetryReadiness() throws Exception { splitFactoryImpl.set(splitFactory, userStorageWrapper); assertNotNull(splitFactory.client()); assertNotNull(splitFactory.manager()); - Thread.sleep(2500); +// await().atMost(3, TimeUnit.SECONDS).until(didTheThing(userStorageWrapper)); + Thread.sleep(2000); Mockito.verify(userStorageWrapper, Mockito.times(2)).connect(); } + /* + private Callable didTheThing(UserStorageWrapper userStorageWrapper) { + return new Callable() { + public Boolean call() throws Exception { + while (!Mockito.verify(userStorageWrapper, Mockito.times(2)).connect()) { + Thread.sleep(3000); + } + return true; + } + }; + } + */ + @Test public void testFactoryConsumerDestroy() throws NoSuchFieldException, URISyntaxException, IllegalAccessException { CustomStorageWrapper customStorageWrapper = Mockito.mock(CustomStorageWrapper.class);