下面列出了怎么用org.junit.jupiter.api.AfterEach的API类实例代码及写法,或者点击链接到github查看源代码。
@AfterEach
public void tearDown() {
DeleteStreamResult result = awsKinesisClient.deleteStream(AWSCommon.DEFAULT_KINESIS_STREAM);
if (result.getSdkHttpMetadata().getHttpStatusCode() != 200) {
fail("Failed to delete the stream");
} else {
try {
// Because of the latency used to simulate the Kinesis API call (defined by the KINESIS_LATENCY) in
// the LocalStack configuration, the test needs to wait at least the same amount of time as set there
// in order to proceed. Otherwise the it fails to create the stream in the setUp phase.
// Ref.: https://github.com/localstack/localstack/issues/231#issuecomment-319959693
Thread.sleep(500);
LOG.info("Stream deleted successfully");
} catch (InterruptedException e) {
fail("Test interrupted while waiting for the stream to cool down");
}
}
awsKinesisClient.shutdown();
deleteKafkaTopic(TestUtils.getDefaultTestTopic(this.getClass()));
}
@AfterEach
void stopServer() throws Exception {
httpServer.close();
List<String> knownClients = Files.readAllLines(knownClientsFile);
assertEquals(2, knownClients.size());
assertEquals("#First line", knownClients.get(0));
assertEquals("foo.com " + fooFingerprint, knownClients.get(1));
}
@AfterEach
public void disposeKSession() throws Exception {
if( ksession != null ) {
ksession.dispose();
ksession = null;
}
}
@AfterEach
public void teardown() throws IOException {
if (Files.exists(KUBE_CONFIG_PATH) && Files.readAllBytes(KUBE_CONFIG_PATH).length == 0) {
Files.delete(KUBE_CONFIG_PATH);
Files.delete(KUBE_CONFIG_DIR);
}
System.clearProperty("kubernetes.master");
}
@AfterEach
void cleanupClient() throws Exception {
client.close();
List<String> knownServers = Files.readAllLines(knownServersFile);
assertEquals(2, knownServers.size(), "Host was verified via TOFU and not CA");
assertEquals("#First line", knownServers.get(0));
assertEquals("localhost:" + fooServer.actualPort() + " " + fooFingerprint, knownServers.get(1));
}
@AfterEach
void cleanupClient() throws Exception {
client.close();
List<String> knownServers = Files.readAllLines(knownServersFile);
assertEquals(2, knownServers.size(), "Host was verified via TOFU and not CA");
assertEquals("#First line", knownServers.get(0));
assertEquals("localhost:" + fooServer.actualPort() + " " + fooFingerprint, knownServers.get(1));
}
@AfterEach
public synchronized void tearDown() {
if (ethSigner != null) {
ethSigner.shutdown();
}
close(unresponsiveSocketA);
close(unresponsiveSocketB);
}
@AfterEach
void cleanup() {
if (ethSigner != null) {
ethSigner.shutdown();
ethSigner = null;
}
}
@AfterEach
void cleanup() {
serverFactory.shutdown();
if (signer != null) {
signer.shutdown();
signer = null;
}
}
@AfterEach
void cleanup() {
if (ethSigner != null) {
ethSigner.shutdown();
ethSigner = null;
}
}
@AfterEach
public void cleanUp() {
if (ethSigner != null) {
ethSigner.shutdown();
ethSigner = null;
}
}
@AfterEach
public void tearDown() {
if (ethNode != null) {
ethNode.shutdown();
}
if (ethSigner != null) {
ethSigner.shutdown();
}
}
@AfterEach
public void tearDown() {
if (session != null) {
session.dispose();
}
kbase = null;
effects = null;
clock = null;
kbuilder = null;
baseConfig = null;
sessionConfig = null;
}
@AfterEach
public void cleanupTempDirectory() {
for (File tempFile : this.tempDirectory.listFiles()) {
tempFile.delete();
}
this.tempDirectory.delete();
}
@AfterEach
void clearRules(RegistryService service) throws Exception {
service.deleteAllGlobalRules();
TestUtils.retry(() -> {
List<RuleType> rules = service.listGlobalRules();
assertEquals(0, rules.size(), "All global rules not deleted");
});
}
@AfterEach
void deleteRules(RegistryService service) throws Exception {
service.deleteAllGlobalRules();
TestUtils.retry(() -> {
List<RuleType> rules = service.listGlobalRules();
assertEquals(0, rules.size(), "All global rules not deleted");
});
}
@AfterEach
void deleteRules(RegistryService service) throws Exception {
service.deleteAllGlobalRules();
TestUtils.retry(() -> {
List<RuleType> rules = service.listGlobalRules();
assertEquals(0, rules.size(), "All global rules not deleted");
});
}
@Override
@AfterEach
public void dropTable() {
getJdbcOperations().execute("DELETE FROM test WHERE 1=1");
getJdbcOperations().execute("DELETE FROM test_two_column WHERE 1=1");
getJdbcOperations().execute("DELETE FROM blob_test WHERE 1=1");
getJdbcOperations().execute("DELETE FROM clob_test WHERE 1=1");
}
@AfterEach
public void tearDown() {
deleteKafkaTopic(TestUtils.getDefaultTestTopic(this.getClass()));
if (!awssqsClient.deleteQueue(queueName)) {
fail("Failed to delete queue");
}
}
@AfterEach
public void tearDown() {
deleteKafkaTopic(TestUtils.getDefaultTestTopic(this.getClass()));
if (!awssqsClient.deleteQueue(queueName)) {
fail("Failed to delete queue");
}
}
@AfterEach
public void tearDown() throws IOException, InterruptedException {
SfdxCommand sfdxCommand = SfdxCommand.forceDataRecordDelete()
.withArgument("--sobjecttype", "Account")
.withArgument("--where", String.format("Name=%s", account));
LOG.debug("Deleting the test account");
ExecResult result = container.execCommand(sfdxCommand);
if (!verifyCommand(sfdxCommand, result)) {
fail("Unable to delete the test account on Salesforce");
}
account = null;
deleteKafkaTopic(TestUtils.getDefaultTestTopic(this.getClass()));
}
@AfterEach
public void tearDown() {
cassandraClient = cassandraService.getClient();
if (testDataDao != null) {
testDataDao.dropTable();
}
deleteKafkaTopic(TestUtils.getDefaultTestTopic(this.getClass()));
}
@After
@AfterEach
public void after()
{
out.reset();
err.reset();
}
@AfterEach
public void cleanup() {
if (this.kieSession != null) {
this.kieSession.dispose();
}
this.statelessKieSession = null;
}
@AfterEach
private void clean() throws IllegalAccessException {
Field convertersField2 = FieldUtils.getDeclaredField(ObjectMapper.class, "_mixIns", true);
SimpleMixInResolver _mixIns = (SimpleMixInResolver) convertersField2.get(Json.mapper());
Field convertersField3 = FieldUtils.getDeclaredField(SimpleMixInResolver.class, "_localMixIns", true);
Map<ClassKey, Class<?>> _localMixIns = (Map<ClassKey, Class<?>>) convertersField3.get(_mixIns);
_localMixIns.putAll(springMixins);
}
@AfterEach
void afterEach() {
if (template != null) {
template.stop();
}
if (context != null) {
context.stop();
}
}
@AfterEach
void tearDown() throws IOException {
packageJsonInputStream.close();
}
@AfterEach
public void clear() {
clearHistory();
}
@AfterEach
public void destroy() {
registry.clear();
}
@AfterEach
public void after() throws IOException {
Files.walk(outputDirectory).sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete);
}