use of com.google.common.testing.TearDown in project commons by twitter.
the class FileUtilsTest method setUp.
@Before
public void setUp() {
final File tmpDir = FileUtils.createTempDir();
addTearDown(new TearDown() {
@Override
public void tearDown() throws Exception {
org.apache.commons.io.FileUtils.deleteDirectory(tmpDir);
}
});
assertEmptyDir(tmpDir);
temporary = new Temporary(tmpDir);
}
use of com.google.common.testing.TearDown in project commons by twitter.
the class SingletonServiceTest method mySetUp.
@Before
@SuppressWarnings("unchecked")
public void mySetUp() throws IOException {
control = createControl();
addTearDown(new TearDown() {
@Override
public void tearDown() {
control.verify();
}
});
listener = control.createMock(SingletonService.LeadershipListener.class);
serverSet = control.createMock(ServerSet.class);
candidate = control.createMock(Candidate.class);
endpointStatus = control.createMock(ServerSet.EndpointStatus.class);
abdicate = control.createMock(ExceptionalCommand.class);
service = new SingletonService(serverSet, candidate);
}
use of com.google.common.testing.TearDown in project guava by google.
the class UninterruptibleFutureTest method setUp.
@Override
protected void setUp() {
final ExecutorService executor = Executors.newSingleThreadExecutor();
tearDownStack.addTearDown(new TearDown() {
@Override
public void tearDown() {
executor.shutdownNow();
}
});
sleeper = new SleepingRunnable(1000);
delayedFuture = executor.submit(sleeper, true);
tearDownStack.addTearDown(new TearDown() {
@Override
public void tearDown() {
Thread.interrupted();
}
});
}
use of com.google.common.testing.TearDown in project guava by google.
the class InterruptionUtil method repeatedlyInterruptTestThread.
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();
}
}
});
}
use of com.google.common.testing.TearDown in project guava by hceylan.
the class InterruptionUtil method repeatedlyInterruptTestThread.
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();
}
}
});
}
Aggregations