​I just observed that Mockito also provides verification after some time..

 Timeout to = new Timeout(2 *
GMSJoinLeave.MEMBER_REQUEST_COLLECTION_INTERVAL, new Times(1));
 verify(messenger, to).send( isA(NetworkPartitionMessage.class));​

>>Is there a way to a sync mechanism (wait/notify, latch, etc) instead of
sleep?  Using sleep() means the test will fail unpredictably.
Basically we are waiting for event to occur in that (approximate) time
period. And it should happen otherwise there is some issue.
In other way,  test has to use timeout otherwise test may hang if event
doesn't happen because of some bug/change.


On Thu, Dec 3, 2015 at 12:56 PM, Kirk Lund <[email protected]> wrote:

> (I also included the following in reviewboard)
>
> I recommend using Awaitility: https://github.com/jayway/awaitility
>
> I've already added it to Geode and written several tests using it. Most of
> my tests are unfortunately languishing on (long-term) feature branches, but
> it looks like others have used it in OplogJUnitTest
> and AutoBalancerIntegrationJUnitTest on develop.
>
> The concept is similar to DistributedTestCase.WaitCriterion but Awaitility
> is much better and more versatile while being a commonly used standard
> library (it's even has some coverage in books on unit testing).
>
> -Kirk
>
>
> On Thu, Dec 3, 2015 at 12:25 PM, Anthony Baker <[email protected]> wrote:
>
>> Is there a way to a sync mechanism (wait/notify, latch, etc) instead of
>> sleep?  Using sleep() means the test will fail unpredictably.
>>
>> Anthony
>>
>>
>> > On Dec 3, 2015, at 11:23 AM, Hitesh Khamesra <[email protected]>
>> wrote:
>> >
>> >
>> >
>> >> On Dec. 3, 2015, 6:55 p.m., Jason Huynh wrote:
>> >>>
>> gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java,
>> line 913
>> >>> <
>> https://reviews.apache.org/r/40850/diff/2/?file=1153051#file1153051line913
>> >
>> >>>
>> >>>    I think i have a similar test in my diff on reviewboard without
>> the sleep.  I'd like to avoid the sleep if at all possible
>> >
>> > In this test NetworkPartitionMessage generated by view creator thread
>> thus needs sleep.
>> >
>> >
>> > - Hitesh
>> >
>> >
>> > -----------------------------------------------------------
>> > This is an automatically generated e-mail. To reply, visit:
>> > https://reviews.apache.org/r/40850/#review108859
>> > -----------------------------------------------------------
>> >
>> >
>> > On Dec. 3, 2015, 6:50 p.m., Hitesh Khamesra wrote:
>> >>
>> >> -----------------------------------------------------------
>> >> This is an automatically generated e-mail. To reply, visit:
>> >> https://reviews.apache.org/r/40850/
>> >> -----------------------------------------------------------
>> >>
>> >> (Updated Dec. 3, 2015, 6:50 p.m.)
>> >>
>> >>
>> >> Review request for geode, anilkumar gingade, Bruce Schuchardt, Jason
>> Huynh, and Jianxia Chen.
>> >>
>> >>
>> >> Repository: geode
>> >>
>> >>
>> >> Description
>> >> -------
>> >>
>> >> GMSJoinLease junit tests
>> >>
>> >>
>> >> Diffs
>> >> -----
>> >>
>> >>
>> gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
>> 2f9c514
>> >>
>> gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java
>> e49e4ae
>> >>
>> >> Diff: https://reviews.apache.org/r/40850/diff/
>> >>
>> >>
>> >> Testing
>> >> -------
>> >>
>> >>
>> >> Thanks,
>> >>
>> >> Hitesh Khamesra
>> >>
>> >>
>> >
>>
>>
>

Reply via email to