本文整理汇总了Java中com.google.common.testing.GcFinalization.awaitDone方法的典型用法代码示例。如果您正苦于以下问题:Java GcFinalization.awaitDone方法的具体用法?Java GcFinalization.awaitDone怎么用?Java GcFinalization.awaitDone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.testing.GcFinalization
的用法示例。
在下文中一共展示了GcFinalization.awaitDone方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testFinalizeDeletesFile
import com.google.common.testing.GcFinalization; //导入方法依赖的package包/类
public void testFinalizeDeletesFile() throws Exception {
byte[] data = newPreFilledByteArray(100);
FileBackedOutputStream out = new FileBackedOutputStream(0, true);
write(out, data, 0, 100, true);
final File file = out.getFile();
assertEquals(100, file.length());
assertTrue(file.exists());
out.close();
// Make sure that finalize deletes the file
out = null;
// times out and throws RuntimeException on failure
GcFinalization.awaitDone(new GcFinalization.FinalizationPredicate() {
@Override
public boolean isDone() {
return !file.exists();
}
});
}
示例2: testFinalizeDeletesFile
import com.google.common.testing.GcFinalization; //导入方法依赖的package包/类
public void testFinalizeDeletesFile() throws Exception {
byte[] data = newPreFilledByteArray(100);
FileBackedOutputStream out = new FileBackedOutputStream(0, true);
write(out, data, 0, 100, true);
final File file = out.getFile();
assertEquals(100, file.length());
assertTrue(file.exists());
out.close();
// Make sure that finalize deletes the file
out = null;
// times out and throws RuntimeException on failure
GcFinalization.awaitDone(
new GcFinalization.FinalizationPredicate() {
@Override
public boolean isDone() {
return !file.exists();
}
});
}
示例3: testFinalizeReferentCalled
import com.google.common.testing.GcFinalization; //导入方法依赖的package包/类
public void testFinalizeReferentCalled() {
final MockReference reference = new MockReference(
frq = new FinalizableReferenceQueue());
GcFinalization.awaitDone(new GcFinalization.FinalizationPredicate() {
public boolean isDone() {
return reference.finalizeReferentCalled;
}
});
}
示例4: garbageCollect
import com.google.common.testing.GcFinalization; //导入方法依赖的package包/类
private void garbageCollect(int expectedSize) {
GcFinalization.awaitDone(new FinalizationPredicate() {
@Override
public boolean isDone() {
store.cleanUp();
return store.size() == expectedSize;
}
});
}
示例5: testFinalizeReferentCalled
import com.google.common.testing.GcFinalization; //导入方法依赖的package包/类
public void testFinalizeReferentCalled() {
final MockReference reference = new MockReference(frq = new FinalizableReferenceQueue());
GcFinalization.awaitDone(
new GcFinalization.FinalizationPredicate() {
public boolean isDone() {
return reference.finalizeReferentCalled;
}
});
}