类org.springframework.test.context.junit4.statements.SpringFailOnTimeout源码实例Demo

下面列出了怎么用org.springframework.test.context.junit4.statements.SpringFailOnTimeout的API类实例代码及写法,或者点击链接到github查看源代码。

@Test
public void userExceptionPropagates() throws Throwable {
	doThrow(new Boom()).when(statement).evaluate();

	exception.expect(Boom.class);
	new SpringFailOnTimeout(statement, 1).evaluate();
}
 
@Test
public void timeoutExceptionThrownIfNoUserException() throws Throwable {
	doAnswer((Answer<Void>) invocation -> {
		TimeUnit.MILLISECONDS.sleep(50);
		return null;
	}).when(statement).evaluate();

	exception.expect(TimeoutException.class);
	new SpringFailOnTimeout(statement, 1).evaluate();
}
 
@Test
public void noExceptionThrownIfNoUserExceptionAndTimeoutDoesNotOccur() throws Throwable {
	doAnswer((Answer<Void>) invocation -> {
		return null;
	}).when(statement).evaluate();

	new SpringFailOnTimeout(statement, 100).evaluate();
}
 
@Test
public void nullNextStatement() throws Throwable {
	exception.expect(IllegalArgumentException.class);
	new SpringFailOnTimeout(null, 1);
}
 
@Test
public void negativeTimeout() throws Throwable {
	exception.expect(IllegalArgumentException.class);
	new SpringFailOnTimeout(statement, -1);
}
 
源代码6 项目: spring-analysis-note   文件: SpringMethodRule.java
/**
 * Wrap the supplied {@link Statement} with a {@code SpringFailOnTimeout} statement.
 * <p>Supports Spring's {@link org.springframework.test.annotation.Timed @Timed}
 * annotation.
 * @see SpringFailOnTimeout
 */
private Statement withPotentialTimeout(Statement next, Method testMethod, Object testInstance) {
	return new SpringFailOnTimeout(next, testMethod);
}
 
源代码7 项目: java-technology-stack   文件: SpringMethodRule.java
/**
 * Wrap the supplied {@link Statement} with a {@code SpringFailOnTimeout} statement.
 * <p>Supports Spring's {@link org.springframework.test.annotation.Timed @Timed}
 * annotation.
 * @see SpringFailOnTimeout
 */
private Statement withPotentialTimeout(Statement next, Method testMethod, Object testInstance) {
	return new SpringFailOnTimeout(next, testMethod);
}
 
源代码8 项目: spring4-understanding   文件: SpringMethodRule.java
/**
 * Wrap the supplied {@link Statement} with a {@code SpringFailOnTimeout} statement.
 * <p>Supports Spring's {@link org.springframework.test.annotation.Timed @Timed}
 * annotation.
 * @see SpringFailOnTimeout
 */
private Statement withPotentialTimeout(Statement next, FrameworkMethod frameworkMethod, Object testInstance) {
	return new SpringFailOnTimeout(next, frameworkMethod.getMethod());
}
 
 同包方法