試圖讓我的GAE 1.9.0項目的單元測試使用maven 3.2.1運行。數據存儲相關測試失敗:Google App Engine數據存儲單元測試使用Maven
java.util.ServiceConfigurationError:
com.google.appengine.tools.development.LocalRpcService:
Provider com.google.appengine.api.datastore.dev.LocalDatastoreV4Service
could not be instantiated: java.lang.NoClassDefFoundError:
com/google/apphosting/datastore/DatastoreV4$LookupRequestOrBuilder
我明白這意味着我錯過了依賴關係。似乎無法找到關於如何正確配置我的pom.xml進行數據存儲測試的文檔。測試崩潰時,我打電話
helper.setup()
的幫手:
public final LocalServiceTestHelper helper = new LocalServiceTestHelper(
new LocalDatastoreServiceTestConfig(),
new LocalTaskQueueTestConfig(),
new LocalBlobstoreServiceTestConfig(),
new LocalUserServiceTestConfig()));
引用:
https://developers.google.com/appengine/docs/java/tools/maven#junit_dependencies_optional
測試依賴於我的pom.xml
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-testing</artifactId>
<version>${appengine.target.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-stubs</artifactId>
<version>${appengine.target.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-labs</artifactId>
<version>${appengine.target.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>3.2.1.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>spring</groupId>
<artifactId>spring-mock</artifactId>
<version>1.0.2</version>
<scope>test</scope>
</dependency>
其餘的堆棧跟蹤:
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: java.lang.NoClassDefFoundError: com/google/apphosting/datastore/DatastoreV4$LookupRequestOrBuilder
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2493)
at java.lang.Class.getConstructor0(Class.java:2803)
at java.lang.Class.newInstance(Class.java:345)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:373)
... 42 more
Caused by: java.lang.ClassNotFoundException: com.google.apphosting.datastore.DatastoreV4$LookupRequestOrBuilder
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
你有沒有找到解決方案? – Keith
沒有對不起 - 我正在對sql數據庫運行集成測試,並將我的db相關測試從gae移除。 – bsautner
我必須做同樣的事情......基本上我只是添加了https://developers.google.com/appengine/docs/java/tools/maven#junit_dependencies_optional部分中提到的依賴關係「爲Google App配置pom.xml設置引擎「,它的工作 – Madhan