improved portability of async code tests by reducing dependencies on time

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/branches/common/common-clients/2.0@58635 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
fabio.simeoni 2012-09-18 10:15:12 +00:00
parent 6b65acf8a8
commit c87ab663b4
1 changed files with 4 additions and 4 deletions

View File

@ -191,7 +191,7 @@ public class AsyncDelegateTest {
Future<?> future = delegate.makeAsync(call,callback);
//make sure we test after call has been delivered
latch.await(1, SECONDS);
latch.await(5, SECONDS);
verify(callback).done(value);
@ -217,8 +217,6 @@ public class AsyncDelegateTest {
Callback<Object> callback = mock(Callback.class);
when(callback.timeout()).thenReturn(50L);
Future<?> future = delegate.makeAsync(call,callback);
final CountDownLatch latch = new CountDownLatch(1);
Answer<?> unblock = new Answer<Object>() {
@ -230,9 +228,11 @@ public class AsyncDelegateTest {
};
doAnswer(unblock).when(callback).onFailure(any(TimeoutException.class));
Future<?> future = delegate.makeAsync(call,callback);
//makes sure callback has been invoked
latch.await(1,SECONDS);
latch.await(5,SECONDS);
assertTrue(future.isCancelled());
}