当前位置: 首页>>代码示例>>Java>>正文


Java FailOnTimeout类代码示例

本文整理汇总了Java中org.junit.internal.runners.statements.FailOnTimeout的典型用法代码示例。如果您正苦于以下问题:Java FailOnTimeout类的具体用法?Java FailOnTimeout怎么用?Java FailOnTimeout使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FailOnTimeout类属于org.junit.internal.runners.statements包,在下文中一共展示了FailOnTimeout类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: apply

import org.junit.internal.runners.statements.FailOnTimeout; //导入依赖的package包/类
public Statement apply(Statement base, Description description)
{
	return new FailOnTimeout(base, TEST_TIMEOUT)
	{
		@Override
		public void evaluate() throws Throwable
		{
			try
			{
				super.evaluate();
				throw new TimeoutException();
			}
			catch(Exception ignored)
			{
			}
		}
	};
}
 
开发者ID:GeorgH93,项目名称:Bukkit_Bungee_PluginLib,代码行数:19,代码来源:UpdaterTest.java

示例2: withPotentialTimeout

import org.junit.internal.runners.statements.FailOnTimeout; //导入依赖的package包/类
@Override
protected Statement withPotentialTimeout(FrameworkMethod method, Object test, Statement next)
{
    Statement result = super.withPotentialTimeout(method, test, next);

    if (result instanceof FailOnTimeout)
    {
        return new Statement()
        {
            @Override
            public void evaluate() throws Throwable
            {
                throw new RuntimeException("@" + Test.class.getName() + "#timeout isn't supported");
            }
        };
    }

    return result;
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:20,代码来源:CdiTestRunner.java

示例3: apply

import org.junit.internal.runners.statements.FailOnTimeout; //导入依赖的package包/类
public Statement apply(Statement base, Description description) {
    if (disabled()) {
        return base;
    } else {
        return new FailOnTimeout(base, (long) this.fMillis);
    }
}
 
开发者ID:altiplanogao,项目名称:io-comparison,代码行数:8,代码来源:Timeout.java

示例4: apply

import org.junit.internal.runners.statements.FailOnTimeout; //导入依赖的package包/类
public Statement apply(Statement base, Description description) {
    if (disabled()) {
        return base;
    } else {
        return new FailOnTimeout(base, fMillis);
    }
}
 
开发者ID:altiplanogao,项目名称:io-comparison,代码行数:8,代码来源:Timeout.java

示例5: apply

import org.junit.internal.runners.statements.FailOnTimeout; //导入依赖的package包/类
public Statement apply(Statement base, Description description) {
    if (fMillis > 0) {
        return new FailOnTimeout(base, fMillis);
    } else {
        return base;
    }
}
 
开发者ID:apache,项目名称:sling-org-apache-sling-testing-rules,代码行数:8,代码来源:TestTimeout.java

示例6: apply

import org.junit.internal.runners.statements.FailOnTimeout; //导入依赖的package包/类
@Override
public Statement apply(Statement base, Description description) {
       return FailOnTimeout.builder()
           .withTimeout(40, SECONDS)
           .withLookingForStuckThread(true)
           .build(base);
}
 
开发者ID:almondtools,项目名称:stringbench,代码行数:8,代码来源:StringBenchIncubation.java

示例7: withPotentialTimeout

import org.junit.internal.runners.statements.FailOnTimeout; //导入依赖的package包/类
/**
 * Returns a {@link Statement}: if {@code method}'s {@code @Test} annotation
 * has the {@code timeout} attribute, throw an exception if {@code next}
 * takes more than the specified number of milliseconds.
 */
@Deprecated
protected Statement withPotentialTimeout(FrameworkMethod method,
        Object test, Statement next) {
    long timeout = getTimeout(method.getAnnotation(Test.class));
    return timeout > 0 ? new FailOnTimeout(next, timeout) : next;
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:12,代码来源:BlockJUnit4ClassRunner.java

示例8: stopEndlessStatement

import org.junit.internal.runners.statements.FailOnTimeout; //导入依赖的package包/类
@Test
public void stopEndlessStatement() throws Throwable {
    InfiniteLoopStatement infiniteLoop = new InfiniteLoopStatement();
    FailOnTimeout infiniteLoopTimeout = new FailOnTimeout(infiniteLoop,
            TIMEOUT);
    try {
        infiniteLoopTimeout.evaluate();
    } catch (Exception timeoutException) {
        sleep(20); // time to interrupt the thread
        int firstCount = InfiniteLoopStatement.COUNT;
        sleep(20); // time to increment the count
        assertTrue("Thread has not been stopped.",
                firstCount == InfiniteLoopStatement.COUNT);
    }
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:16,代码来源:FailOnTimeoutTest.java

示例9: stackTraceContainsRealCauseOfTimeout

import org.junit.internal.runners.statements.FailOnTimeout; //导入依赖的package包/类
@Test
public void stackTraceContainsRealCauseOfTimeout() throws Throwable {
    StuckStatement stuck = new StuckStatement();
    FailOnTimeout stuckTimeout = new FailOnTimeout(stuck, TIMEOUT);
    try {
        stuckTimeout.evaluate();
        // We must not get here, we expect a timeout exception
        fail("Expected timeout exception");
    } catch (Exception timeoutException) {
        StackTraceElement[] stackTrace = timeoutException.getStackTrace();
        boolean stackTraceContainsTheRealCauseOfTheTimeout = false;
        boolean stackTraceContainsOtherThanTheRealCauseOfTheTimeout = false;
        for (StackTraceElement element : stackTrace) {
            String methodName = element.getMethodName();
            if ("theRealCauseOfTheTimeout".equals(methodName)) {
                stackTraceContainsTheRealCauseOfTheTimeout = true;
            }
            if ("notTheRealCauseOfTheTimeout".equals(methodName)) {
                stackTraceContainsOtherThanTheRealCauseOfTheTimeout = true;
            }
        }
        assertTrue(
                "Stack trace does not contain the real cause of the timeout",
                stackTraceContainsTheRealCauseOfTheTimeout);
        assertFalse(
                "Stack trace contains other than the real cause of the timeout, which can be very misleading",
                stackTraceContainsOtherThanTheRealCauseOfTheTimeout);
    }
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:30,代码来源:FailOnTimeoutTest.java

示例10: withPotentialTimeout

import org.junit.internal.runners.statements.FailOnTimeout; //导入依赖的package包/类
/**
 * Perform the same logic as
 * {@link BlockJUnit4ClassRunner#withPotentialTimeout(FrameworkMethod, Object, Statement)}
 * but with additional support for changing the coded timeout with an extended value.
 *
 * @return either a {@link FailOnTimeout}, or the supplied {@link Statement} as appropriate.
 */
@SuppressWarnings("deprecation")
@Override
protected Statement withPotentialTimeout(FrameworkMethod frameworkMethod, Object testInstance, Statement next) {
    long testTimeout = getOriginalTimeout(frameworkMethod);

    if (testTimeout > 0) {
        String multiplierString = System.getProperty("org.apache.qpid.jms.testTimeoutMultiplier");
        double multiplier = 0.0;

        try {
            multiplier = Double.parseDouble(multiplierString);
        } catch (NullPointerException npe) {
        } catch (NumberFormatException nfe) {
            LOG.warn("Ignoring testTimeoutMultiplier not set to a valid value: " + multiplierString);
        }

        if (multiplier > 0.0) {
            LOG.info("Test timeout multiple {} applied to test timeout {}ms: new timeout = {}",
                multiplier, testTimeout, (long) (testTimeout * multiplier));
            testTimeout = (long) (testTimeout * multiplier);
        }

        next = FailOnTimeout.builder().
            withTimeout(testTimeout, TimeUnit.MILLISECONDS).build(next);
    } else {
        next = super.withPotentialTimeout(frameworkMethod, testInstance, next);
    }

    return next;
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:38,代码来源:QpidJMSTestRunner.java

示例11: whenTestAnnotationDoesSpecifyATimeout_returnFailOnTimeoutStatement

import org.junit.internal.runners.statements.FailOnTimeout; //导入依赖的package包/类
@Test
public void whenTestAnnotationDoesSpecifyATimeout_returnFailOnTimeoutStatement() throws Exception {
    TestClass testClass = TestClassPool.forClass(SingleTestWithTimeoutAnnotation.class);
    FrameworkMethod method = testClass.getAnnotatedMethods(Test.class).get(0);

    Statement actual = builder.createStatement(testClass, method, target, next, description, notifier);
    assertThat(actual, is(instanceOf(FailOnTimeout.class)));
}
 
开发者ID:bechte,项目名称:junit-hierarchicalcontextrunner,代码行数:9,代码来源:FailOnTimeoutStatementBuilderTest.java

示例12: apply

import org.junit.internal.runners.statements.FailOnTimeout; //导入依赖的package包/类
public Statement apply(Statement base, Description description) {
    return new FailOnTimeout(base, fTimeout, fTimeUnit, fLookForStuckThread);
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:4,代码来源:Timeout.java

示例13: apply

import org.junit.internal.runners.statements.FailOnTimeout; //导入依赖的package包/类
public Statement apply(Statement base, Description description) {
    return new FailOnTimeout(base, fMillis);
}
 
开发者ID:lcm-proj,项目名称:lcm,代码行数:4,代码来源:Timeout.java

示例14: createStatement

import org.junit.internal.runners.statements.FailOnTimeout; //导入依赖的package包/类
public Statement createStatement(final TestClass testClass, final FrameworkMethod method, final Object target,
                                 final Statement next, final Description description, final RunNotifier notifier) {
    final Test annotation = method.getAnnotation(Test.class);
    return annotation.timeout() <= 0 ? next : new FailOnTimeout(next, annotation.timeout());
}
 
开发者ID:bechte,项目名称:junit-hierarchicalcontextrunner,代码行数:6,代码来源:FailOnTimeoutStatementBuilder.java

示例15: withPotentialTimeout

import org.junit.internal.runners.statements.FailOnTimeout; //导入依赖的package包/类
/**
 * Returns a {@link org.junit.runners.model.Statement}: if {@code method}'s {@code @Test} annotation
 * has the {@code timeout} attribute, throw an exception if {@code next}
 * takes more than the specified number of milliseconds.
 *
 * @deprecated Will be private soon: use Rules instead
 */
@Deprecated
protected Statement withPotentialTimeout(FrameworkMethod method,
        Object test, Statement next) {
    long timeout = getTimeout(method.getAnnotation(Test.class));
    return timeout > 0 ? new FailOnTimeout(next, timeout) : next;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:14,代码来源:LoadTimeWeavableTestRunner.java


注:本文中的org.junit.internal.runners.statements.FailOnTimeout类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。