这里发生了奇怪的事情。运行任何调用的单元测试时:
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)
答案 0 :(得分:3)
您可以通过向LocalServiceTestHelper设置添加LocalBlobstoreServiceTestConfig()来避免这种情况。在将其添加到失败的测试类之后,我才开始工作。
我不确定这确实是一个错误。我认为这个bug是在SDK提供本地blobstore仿真之前没有正确的测试设置配置。