下面列出了org.junit.jupiter.api.AfterEach#org.junit.After 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@After
@Override
public void tearDown() throws Exception {
try {
// Some tests may call tomcat.destroy(), some tests may just call
// tomcat.stop(), some not call either method. Make sure that stop()
// & destroy() are called as necessary.
if (tomcat.server != null
&& tomcat.server.getState() != LifecycleState.DESTROYED) {
if (tomcat.server.getState() != LifecycleState.STOPPED) {
tomcat.stop();
}
tomcat.destroy();
}
} finally {
super.tearDown();
}
}
@After
public void teardown() throws InterruptedException {
if (clientChannel != null) {
clientChannel.close().sync();
clientChannel = null;
}
if (serverChannel != null) {
serverChannel.close().sync();
serverChannel = null;
}
final Channel serverConnectedChannel = this.serverConnectedChannel;
if (serverConnectedChannel != null) {
serverConnectedChannel.close().sync();
this.serverConnectedChannel = null;
}
Future<?> serverGroup = sb.config().group().shutdownGracefully(0, 0, MILLISECONDS);
Future<?> serverChildGroup = sb.config().childGroup().shutdownGracefully(0, 0, MILLISECONDS);
Future<?> clientGroup = cb.config().group().shutdownGracefully(0, 0, MILLISECONDS);
serverGroup.sync();
serverChildGroup.sync();
clientGroup.sync();
}
@After
public void afterTest() {
if (this.memoryManager != null) {
Assert.assertTrue("Memory Leak: Not all memory has been returned to the memory manager.",
this.memoryManager.verifyEmpty());
this.memoryManager.shutdown();
this.memoryManager = null;
}
if (this.ioManager != null) {
this.ioManager.shutdown();
if (!this.ioManager.isProperlyShutDown()) {
Assert.fail("I/O manager failed to properly shut down.");
}
this.ioManager = null;
}
}
/**
* Shutdown MiniDFSCluster.
*/
@After
public void shutdown() {
if (cluster != null) {
cluster.shutdown();
}
FileUtils.deleteQuietly(metaDir.toFile());
}
@After
public void after() {
System.clearProperty("noBuild");
System.clearProperty("isDeveloperMode");
System.clearProperty("spark.local");
super.after();
}
@After
public void teardown() throws Exception {
cliClientService.shutdown();
cluster.stopAll();
if (NodeImpl.GLOBAL_NUM_NODES.get() > 0) {
Thread.sleep(1000);
assertEquals(NodeImpl.GLOBAL_NUM_NODES.get(), 0);
}
FileUtils.deleteDirectory(new File(this.dataPath));
NodeManager.getInstance().clear();
RouteTable.getInstance().reset();
}
@After
@Override
public void tearDown() throws Exception
{
super.tearDown();
verify();
reset();
}
@After
@Override
public void shutdownBlobServer() throws IOException {
if (blobServer != null) {
blobServer.close();
}
}
@After
public final void afterTest() throws Exception {
completeStrayTransaction();
if ( isCleanupTestDataRequired() ) {
cleanupTestData();
}
cleanupTest();
cleanupSession();
assertAllDataRemoved();
}
@After
public void tearDown()
throws Exception
{
allocator.close();
logger.info("{}: exit ", testName.getMethodName());
}
@After
public void tearDown() {
transformData = null;
keysMeta = null;
keys = null;
data = null;
}
@After
public void tearDown() {
if (server != null) {
server.shutdown();
}
if (channel != null) {
channel.shutdown();
}
MoreExecutors.shutdownAndAwaitTermination(executor, 5, TimeUnit.SECONDS);
}
@After
public void clearOutputTable() throws Exception {
Class.forName(DRIVER_CLASS);
try (
Connection conn = DriverManager.getConnection(DB_URL);
Statement stat = conn.createStatement()) {
stat.execute("DELETE FROM " + OUTPUT_TABLE);
stat.close();
conn.close();
}
}
@After
public void teardown() {
// Delete all records
Datastore datastore = getService();
Query<Entity> query = Query.newEntityQueryBuilder().setKind(CACHE_KIND).build();
QueryResults<Entity> entities = datastore.run(query);
while (entities.hasNext()) {
Entity entity = entities.next();
datastore.delete(entity.getKey());
}
}
@After
public void teardown() throws Exception {
if (resourceManager != null) {
RpcUtils.terminateRpcEndpoint(resourceManager, TIMEOUT);
}
if (testingFatalErrorHandler != null && testingFatalErrorHandler.hasExceptionOccurred()) {
testingFatalErrorHandler.rethrowError();
}
}
@After
public void removeAllRecord() throws Exception {
SysUserService userService = new SysUserService();
List<SysUser> userList = userService.queryPageList("", null, null, null, null, 0, 10);
assertTrue(userList.size() > 0);
for (SysUser user : userList) {
userService.delete(user.getId());
}
}
@After
public void destroyHDFS() {
try {
if (baseDir != null) {
FileUtil.fullyDelete(baseDir);
}
} catch (Throwable t) {
throw new RuntimeException(t);
}
}
@After
public void after() {
LogStreamManager.getInstance().getSingerLogPaths().clear();
SingerSettings.getFsMonitorMap().clear();
delete(new File(podLogPath));
LogStreamManager.reset();
KubeService.reset();
SingerSettings.reset();
}
@After
public void cleanDb(TestContext context) {
test( context, openSession()
.thenCompose( s -> s.remove( spelt ) )
.thenCompose( s -> s.remove( rye ) )
.thenCompose( s -> s.remove( almond ) )
.thenCompose( s -> s.flush() ) );
}
@After
public void afterTest() {
if (!this.memoryManager.verifyEmpty()) {
Assert.fail("Memory Leak: Some memory has not been returned to the memory manager.");
}
if (this.memoryManager != null) {
this.memoryManager.shutdown();
this.memoryManager = null;
}
}
@After
// named differently than tearDown(), so subclasses do not override it
public void dockingTearDown() {
// Disable error reporting from non-test threads found during tearDown(). The idea is
// that odd issue find while coming down are not important, as they are usually
// timing issues.
// Note: this doesn't quite work as intended. This should be run before each other
// tearDown() method, but junit offers no way to do that. If you can figure
// out how to make that work, then update this code.
ConcurrentTestExceptionHandler.disable();
}
@After
public void cleanUp() throws Exception {
if (volumeSet != null) {
volumeSet.shutdown();
volumeSet = null;
}
}
@After
public void clearResource() {
RedisCommands<String, String> stringRedisCommands = client.connect().sync();
stringRedisCommands.del(ruleKey);
client.shutdown();
server.stop();
server = null;
}
@After
public void cleanup() throws Exception {
getFileSystem().delete(basePathForTest, true);
}
@After
public void destroy() {
teamRepo.deleteAll();
}
@After
public void tearDown() {
super.shutdown();
}
@Override
@After
public void teardown() throws Exception {
this.logStorage.shutdown();
super.teardown();
}
@After
public void verifyRestoredRequestAttributes() {
assertRequestAttributes(false);
}
@After
public void tearDown() throws Exception {
}
@After
public void tearDown() throws Exception {
}