在将App Engine SDK更新到1.7.0之后,我们的一些单元测试开始失败。
在SDK 1.6.x中,我断言删除了一个blob,如下所示:
try {
fileService.getBlobFile(blobKey);
Assert.fail("Blob not deleted: " + blobKey);
} catch (FileNotFoundException expected) {
// OK
}在SDK1.7.0中,getBlobFile()不再抛出FileNotFoundException。
我试图引发一个异常,但没有成功(没有抛出异常):
try {
AppEngineFile blobFile = fileService.getBlobFile(blobKey);
boolean readable = blobFile.isReadable();
FileReadChannel channel = fileService.openReadChannel(blobFile, false);
channel.position(1);
try {
channel.close();
} catch (Exception e) {
// Silent
}
Assert.fail("Blob not deleted: " + blobKey);
} catch (Exception expected) {
// OK
}斑点应该被删除,但是可以为它打开一个通道...
那么,在单元测试中如何检查删除是否成功呢?
发布于 2012-06-30 07:02:45
尝试使用blobstoreService.fetchData检索文件的第一个字节。
如果文件不存在,它将抛出。
发布于 2012-06-30 12:20:39
App Engine尚不支持JDK 1.7。
https://stackoverflow.com/questions/11268806
复制相似问题