0

这里发生了奇怪的事情。运行任何调用的单元测试时:

FileService fileService = FileServiceFactory.getFileService();
writeChannel = fileService.openWriteChannel(file, lock);
writeChannel.closeFinally(); 

我得到以下异常 - 代码在单元测试之外和其他工作站上运行良好 - 所以这是我被迫使用的 Windows XP 笔记本电脑上的环境问题。测试在我的其他电脑和笔记本电脑上运行良好(运行 ubuntu)

java.lang.RuntimeException: illegal blobKey: pIONuF92LGIK8TV41YSSdQ
    at com.google.appengine.api.blobstore.dev.FileBlobStorage.getFileForBlob(FileBlobStorage.java:95)
    at com.google.appengine.api.blobstore.dev.FileBlobStorage.storeBlob(FileBlobStorage.java:45)
    at com.google.appengine.api.files.dev.BlobstoreFile.getOutputStream(BlobstoreFile.java:225)
    at com.google.appengine.api.files.dev.FileMetadata.setFinalized(FileMetadata.java:97)
    at com.google.appengine.api.files.dev.BlobstoreFile.setFinalized(BlobstoreFile.java:212)
    at com.google.appengine.api.files.dev.LocalFileService.close(LocalFileService.java:334)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at com.google.appengine.tools.development.ApiProxyLocalImpl$AsyncApiCall.callInternal(ApiProxyLocalImpl.java:498)
    at com.google.appengine.tools.development.ApiProxyLocalImpl$AsyncApiCall.call(ApiProxyLocalImpl.java:452)
    at com.google.appengine.tools.development.ApiProxyLocalImpl$AsyncApiCall.call(ApiProxyLocalImpl.java:430)
    at java.util.concurrent.Executors$PrivilegedCallable$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.util.concurrent.Executors$PrivilegedCallable.call(Unknown Source)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
4

1 回答 1

3

您可以通过将 LocalBlobstoreServiceTestConfig() 添加到 LocalServiceTestHelper 设置来避免这种情况。在将它添加到失败的测试类后,我才让它工作。

我不确定这是否确实是一个错误。我认为该错误是在 SDK 提供本地 blobstore 仿真而没有正确的测试设置配置之前。

于 2012-04-13T13:09:53.627 回答