本文整理汇总了Java中com.google.common.testing.TearDownAccepter.addTearDown方法的典型用法代码示例。如果您正苦于以下问题:Java TearDownAccepter.addTearDown方法的具体用法?Java TearDownAccepter.addTearDown怎么用?Java TearDownAccepter.addTearDown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.testing.TearDownAccepter
的用法示例。
在下文中一共展示了TearDownAccepter.addTearDown方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: repeatedlyInterruptTestThread
import com.google.common.testing.TearDownAccepter; //导入方法依赖的package包/类
static void repeatedlyInterruptTestThread(
long interruptPeriodMillis, TearDownAccepter tearDownAccepter) {
final Interruptenator interruptingTask =
new Interruptenator(Thread.currentThread(), interruptPeriodMillis);
final Thread interruptingThread = new Thread(interruptingTask);
interruptingThread.start();
tearDownAccepter.addTearDown(new TearDown() {
@Override public void tearDown() throws Exception {
interruptingTask.stopInterrupting();
interruptingThread.interrupt();
joinUninterruptibly(interruptingThread, 2500, MILLISECONDS);
Thread.interrupted();
if (interruptingThread.isAlive()) {
// This will be hidden by test-output redirection:
logger.severe(
"InterruptenatorTask did not exit; future tests may be affected");
/*
* This won't do any good under JUnit 3, but I'll leave it around in
* case we ever switch to JUnit 4:
*/
fail();
}
}
});
}
示例2: getTestWrapper
import com.google.common.testing.TearDownAccepter; //导入方法依赖的package包/类
@Provides
@Singleton
TestWrapper getTestWrapper(final TestId testId,
final TearDownAccepter tearDownAccepter) {
return new TestWrapper() {
public void toRunBeforeTest() {
tearDownAccepter.addTearDown(new TearDown() {
public void tearDown() throws Exception {
System.out.println("Ending: " + testId);
}
});
System.out.println("Beginning: " + testId);
}
};
}
示例3: getTestWrapper
import com.google.common.testing.TearDownAccepter; //导入方法依赖的package包/类
@Provides
TestWrapper getTestWrapper(final TestId testId,
final TearDownAccepter tearDownAccepter) {
return new TestWrapper() {
public void toRunBeforeTest() {
tearDownAccepter.addTearDown(new TearDown() {
public void tearDown() throws Exception {
System.out.println("Ending: " + testId);
}
});
System.out.println("Beginning: " + testId);
}
};
}
示例4: repeatedlyInterruptTestThread
import com.google.common.testing.TearDownAccepter; //导入方法依赖的package包/类
static void repeatedlyInterruptTestThread(
long interruptPeriodMillis, TearDownAccepter tearDownAccepter) {
final Interruptenator interruptingTask =
new Interruptenator(Thread.currentThread(), interruptPeriodMillis);
final Thread interruptingThread = new Thread(interruptingTask);
interruptingThread.start();
tearDownAccepter.addTearDown(
new TearDown() {
@Override
public void tearDown() throws Exception {
interruptingTask.stopInterrupting();
interruptingThread.interrupt();
joinUninterruptibly(interruptingThread, 2500, MILLISECONDS);
Thread.interrupted();
if (interruptingThread.isAlive()) {
// This will be hidden by test-output redirection:
logger.severe("InterruptenatorTask did not exit; future tests may be affected");
/*
* This won't do any good under JUnit 3, but I'll leave it around in
* case we ever switch to JUnit 4:
*/
fail();
}
}
});
}
示例5: adapt
import com.google.common.testing.TearDownAccepter; //导入方法依赖的package包/类
private static TestWrapper adapt(
final com.google.inject.testing.guiceberry.TestScopeListener instance,
final TearDownAccepter tearDownAccepter) {
return new TestWrapper() {
public void toRunBeforeTest() {
tearDownAccepter.addTearDown(new TearDown() {
public void tearDown() throws Exception {
instance.exitingScope();
}
});
instance.enteringScope();
}
};
}
示例6: maybeAddGuiceBerryTearDown
import com.google.common.testing.TearDownAccepter; //导入方法依赖的package包/类
@Deprecated
public static void maybeAddGuiceBerryTearDown(
ThreadLocal<TearDown> scaffoldingThreadLocal, final TestDescription testDescription,
final TearDown toTearDown) {
Object testToTearDown = testDescription.getTestCase();
if (testToTearDown instanceof TearDownAccepter) {
TearDownAccepter tdtc = (TearDownAccepter) testToTearDown;
tdtc.addTearDown(toTearDown);
} else {
scaffoldingThreadLocal.set(toTearDown);
}
}
示例7: getWrapper
import com.google.common.testing.TearDownAccepter; //导入方法依赖的package包/类
@SuppressWarnings("unused")
@Provides
TestWrapper getWrapper(final TearDownAccepter tearDownAccepter) {
return new TestWrapper() {
public void toRunBeforeTest() {
tearDownAccepter.addTearDown(new TearDown() {
public void tearDown() throws Exception {
beforeTestTearDownHasRun = true;
}
});
throw new RuntimeException("kaboom");
}
};
}