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

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

下面列出了org.springframework.test.context.junit4.statements.SpringFailOnTimeout 类实例代码,或者点击链接到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());
}
 
源代码评论
动弹
沙发等你来抢
 类方法
 同包方法