Java 类org.mockito.verification.VerificationWithTimeout 实例源码

项目:securemock    文件:Mockito.java   
public static VerificationWithTimeout timeout(final int millis) {
    return AccessController.doPrivileged(new PrivilegedAction<VerificationWithTimeout>() {
        @Override
        public VerificationWithTimeout run() {
            return org.mockito.Mockito.timeout(millis);
        }
    });
}
项目:mockito-java8    文件:WithMockito.java   
/**
 * Delegates call to {@link Mockito#timeout(long)}.
 */
default VerificationWithTimeout timeout(long millis) {
    return Mockito.timeout(millis);
}
项目:extended-mockito    文件:MockitoMixin.java   
/**
 * Delegate call to public static org.mockito.verification.VerificationWithTimeout org.mockito.Mockito.timeout(long)
 * {@link org.mockito.Mockito#timeout(long)}
 */
default VerificationWithTimeout timeout(long millis) {
    return Mockito.timeout(millis);
}
项目:interface-it    文件:MockitoMixinWithSupertype.java   
/**
 * Delegate call to public static org.mockito.verification.VerificationWithTimeout org.mockito.Mockito.timeout(long)
 * {@link org.mockito.Mockito#timeout(long)}
 */
default VerificationWithTimeout timeout(long millis) {
    return Mockito.timeout(millis);
}
项目:interface-it    文件:Mockito.java   
/**
 * Delegate call to public static org.mockito.verification.VerificationWithTimeout org.mockito.Mockito.timeout(long)
 * {@link org.mockito.Mockito#timeout(long)}
 */
default VerificationWithTimeout timeout(long millis) {
    return org.mockito.Mockito.timeout(millis);
}
项目:astor    文件:Mockito.java   
/**
 * Allows verifying with timeout. May be useful for testing in concurrent conditions.
 * <p>
 * It feels this feature should be used rarely - figure out a better way of testing your multi-threaded system
 * <p>
 * Not yet implemented to work with InOrder verification.
 * <pre>
 *   //passes when someMethod() is called within given time span 
 *   verify(mock, timeout(100)).someMethod();
 *   //above is an alias to:
 *   verify(mock, timeout(100).times(1)).someMethod();
 *   
 *   //passes when someMethod() is called *exactly* 2 times within given time span
 *   verify(mock, timeout(100).times(2)).someMethod();
 *
 *   //passes when someMethod() is called *at lest* 2 times within given time span
 *   verify(mock, timeout(100).atLeast(2)).someMethod();
 *   
 *   //verifies someMethod() within given time span using given verification mode
 *   //useful only if you have your own custom verification modes.
 *   verify(mock, new Timeout(100, yourOwnVerificationMode)).someMethod();
 * </pre>
 * 
 * See examples in javadoc for {@link Mockito} class
 * 
 * @param millis - time span in millis
 * 
 * @return verification mode
 */
public static VerificationWithTimeout timeout(int millis) {
    return new Timeout(millis, VerificationModeFactory.times(1));
}
项目:astor    文件:Mockito.java   
/**
 * Allows verifying with timeout. It causes a verify to wait for a specified period of time for a desired
 * interaction rather than fails immediately if has not already happened. May be useful for testing in concurrent
 * conditions.
 * <p>
 * This differs from {@link Mockito#after after()} in that after() will wait the full period, unless
 * the final test result is known early (e.g. if a never() fails), whereas timeout() will stop early as soon
 * as verification passes, producing different behaviour when used with times(2), for example, which can pass 
 * and then later fail. In that case, timeout would pass as soon as times(2) passes, whereas after would run until
 * times(2) failed, and then fail.
 * <p>
 * It feels this feature should be used rarely - figure out a better way of testing your multi-threaded system
 * <p>
 * Not yet implemented to work with InOrder verification.
 * <pre class="code"><code class="java">
 *   //passes when someMethod() is called within given time span 
 *   verify(mock, timeout(100)).someMethod();
 *   //above is an alias to:
 *   verify(mock, timeout(100).times(1)).someMethod();
 *   
 *   //passes as soon as someMethod() has been called 2 times before the given timeout
 *   verify(mock, timeout(100).times(2)).someMethod();
 *
 *   //equivalent: this also passes as soon as someMethod() has been called 2 times before the given timeout
 *   verify(mock, timeout(100).atLeast(2)).someMethod();
 *   
 *   //verifies someMethod() within given time span using given verification mode
 *   //useful only if you have your own custom verification modes.
 *   verify(mock, new Timeout(100, yourOwnVerificationMode)).someMethod();
 * </code></pre>
 * 
 * See examples in javadoc for {@link Mockito} class
 * 
 * @param millis - time span in milliseconds
 * 
 * @return verification mode
 */
public static VerificationWithTimeout timeout(int millis) {
    return new Timeout(millis, VerificationModeFactory.times(1));
}