Skip to content

Commit

Permalink
tyring to work around sleep code smell
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilal Al committed Sep 5, 2024
1 parent f1c8a7f commit bcd9ac8
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions client/src/test/java/io/split/client/SplitFactoryImplTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,22 @@ public void testFactoryConsumerInstantiationRetryReadiness() throws Exception {
modifiersField.setAccessible(true);
modifiersField.setInt(splitFactoryImpl, splitFactoryImpl.getModifiers() & ~Modifier.FINAL);
splitFactoryImpl.set(splitFactory, userStorageWrapper);
Thread.sleep(2000);
assertNotNull(splitFactory.client());
assertNotNull(splitFactory.manager());
Thread.sleep(1000);
Thread.sleep(2000);
await().atMost(3, TimeUnit.SECONDS).until(didTheThing(userStorageWrapper));
Mockito.verify(userStorageWrapper, Mockito.times(2)).connect();
}

private Callable<Boolean> didTheThing(UserStorageWrapper userStorageWrapper) {
return new Callable<Boolean>() {
public Boolean call() throws Exception {
Thread.sleep(1000);
return true;
}
};
}

@Test
public void testFactoryConsumerDestroy() throws NoSuchFieldException, URISyntaxException, IllegalAccessException {
CustomStorageWrapper customStorageWrapper = Mockito.mock(CustomStorageWrapper.class);
Expand Down

0 comments on commit bcd9ac8

Please sign in to comment.