使用GAE / Arquillian运行Servlet测试时出错

时间:2014-03-07 10:31:48

标签: java google-app-engine shrinkwrap jboss-arquillian

我试图运行:

$ mvn -Dtest=AnnotatedEchoServletTestCase test -Dappengine.sdk.root=/home/xybrek/buildtools/appengine-java-sdk-1.8.4

这是日志:


T E S T S

Running com.myapp.AnnotatedEchoServletTestCase
Mar 07, 2014 6:15:20 PM org.jboss.arquillian.container.appengine.embedded.AppEngineSetup prepare
INFO: servlet-test.war:
/WEB-INF/
/WEB-INF/lib/
/WEB-INF/lib/appengine-api-1.0-sdk-1.8.4.jar
/WEB-INF/classes/
/WEB-INF/classes/com/
/WEB-INF/classes/com/myapp/
/WEB-INF/classes/com/myapp/EchoServlet.class
/WEB-INF/classes/org/
/WEB-INF/classes/org/jboss/
/WEB-INF/classes/org/jboss/arquillian/
/WEB-INF/classes/org/jboss/arquillian/container/
/WEB-INF/classes/org/jboss/arquillian/container/appengine/
/WEB-INF/classes/org/jboss/arquillian/container/appengine/embedded/
/WEB-INF/classes/org/jboss/arquillian/container/appengine/embedded/hack/
/WEB-INF/classes/org/jboss/arquillian/container/appengine/embedded/hack/AppEngineHack.class
/WEB-INF/classes/org/jboss/arquillian/container/appengine/embedded/hack/AppEngineHack$1.class
/WEB-INF/classes/org/jboss/arquillian/container/appengine/embedded/hack/AppEngineHack$2.class
Mar 07, 2014 6:15:20 PM org.jboss.arquillian.container.common.AppEngineCommonContainer$1 run
INFO: Get temp root: /tmp
Mar 07, 2014 6:15:21 PM com.google.apphosting.utils.config.AppEngineWebXmlReader readAppEngineWebXml
SEVERE: Received exception processing /tmp/servlet-test.war/WEB-INF/appengine-web.xml
com.google.apphosting.utils.config.AppEngineConfigException: Could not locate /tmp/servlet-test.war/WEB-INF/appengine-web.xml
  at com.google.apphosting.utils.config.AppEngineWebXmlReader.getInputStream(AppEngineWebXmlReader.java:140)
  at com.google.apphosting.utils.config.AppEngineWebXmlReader.readAppEngineWebXml(AppEngineWebXmlReader.java:75)
  at com.google.apphosting.utils.config.EarHelper.readWebModule(EarHelper.java:166)
  at com.google.appengine.tools.development.ApplicationConfigurationManager$WarModuleConfigurationHandle.readConfiguration(ApplicationConfigurationManager.java:399)
  at com.google.appengine.tools.development.ApplicationConfigurationManager.<init>(ApplicationConfigurationManager.java:146)
  at com.google.appengine.tools.development.ApplicationConfigurationManager.newWarConfigurationManager(ApplicationConfigurationManager.java:88)
  at com.google.appengine.tools.development.DevAppServerImpl.<init>(DevAppServerImpl.java:137)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
  at org.jboss.arquillian.container.appengine.embedded.hack.DevAppServerFactoryHack.createDevAppServer(DevAppServerFactoryHack.java:36)
  at org.jboss.arquillian.container.appengine.embedded.hack.DevAppServerFactoryHack.createDevAppServer(DevAppServerFactoryHack.java:25)
  at org.jboss.arquillian.container.appengine.embedded.AppEngineEmbeddedContainer$1.run(AppEngineEmbeddedContainer.java:68)
  at org.jboss.arquillian.container.appengine.embedded.AppEngineEmbeddedContainer$1.run(AppEngineEmbeddedContainer.java:66)
  at java.security.AccessController.doPrivileged(Native Method)
  at org.jboss.arquillian.container.appengine.embedded.AppEngineEmbeddedContainer.doDeploy(AppEngineEmbeddedContainer.java:66)
  at org.jboss.arquillian.container.common.AppEngineCommonContainer.deploy(AppEngineCommonContainer.java:94)
  at org.jboss.arquillian.container.impl.client.container.ContainerDeployController$3.call(ContainerDeployController.java:161)
  at org.jboss.arquillian.container.impl.client.container.ContainerDeployController$3.call(ContainerDeployController.java:128)
  at org.jboss.arquillian.container.impl.client.container.ContainerDeployController.executeOperation(ContainerDeployController.java:271)
  at org.jboss.arquillian.container.impl.client.container.ContainerDeployController.deploy(ContainerDeployController.java:127)
  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.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
  at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
  at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
  at org.jboss.arquillian.container.impl.client.container.DeploymentExceptionHandler.verifyExpectedExceptionDuringDeploy(DeploymentExceptionHandler.java:50)
  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.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
  at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
  at org.jboss.arquillian.container.impl.client.ContainerDeploymentContextHandler.createDeploymentContext(ContainerDeploymentContextHandler.java:78)
  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.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
  at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
  at org.jboss.arquillian.container.impl.client.ContainerDeploymentContextHandler.createContainerContext(ContainerDeploymentContextHandler.java:57)
  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.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
  at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
  at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
  at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
  at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
  at org.jboss.arquillian.container.impl.client.container.ContainerDeployController$1.perform(ContainerDeployController.java:95)
  at org.jboss.arquillian.container.impl.client.container.ContainerDeployController$1.perform(ContainerDeployController.java:80)
  at org.jboss.arquillian.container.impl.client.container.ContainerDeployController.forEachDeployment(ContainerDeployController.java:263)
  at org.jboss.arquillian.container.impl.client.container.ContainerDeployController.forEachManagedDeployment(ContainerDeployController.java:239)
  at org.jboss.arquillian.container.impl.client.container.ContainerDeployController.deployManaged(ContainerDeployController.java:79)
  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.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
  at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
  at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
  at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
  at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
  at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
  at org.jboss.arquillian.container.test.impl.client.ContainerEventController.execute(ContainerEventController.java:101)
  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.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
  at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
  at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
  at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:75)
  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.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
  at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
  at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:60)
  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.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
  at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
  at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
  at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
  at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.beforeClass(EventTestRunnerAdaptor.java:80)
  at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:182)
  at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:314)
  at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:46)
  at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:199)
  at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
  at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:147)
  at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53)
  at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123)
  at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104)
  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:164)
  at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
  at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175)
  at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107)
  at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68)
Caused by: java.io.FileNotFoundException: /tmp/servlet-test.war/WEB-INF/appengine-web.xml (No such file or directory)
  at java.io.FileInputStream.open(Native Method)
  at java.io.FileInputStream.<init>(FileInputStream.java:146)
  at java.io.FileInputStream.<init>(FileInputStream.java:101)
  at com.google.apphosting.utils.config.AppEngineWebXmlReader.getInputStream(AppEngineWebXmlReader.java:137)
  ... 110 more

测试运行:1,失败:0,错误:1,跳过:0,经过时间:2.826秒&lt;&lt;&lt; FAILURE!

结果:

错误测试:

com.myapp。AnnotatedEchoServletTestCase:启动AppEngine时出错。

似乎无法找到:com.google.apphosting.utils.config.AppEngineConfigException: Could not locate /tmp/servlet-test.war/WEB-INF/appengine-web.xml

/src/main/webapp/WEB-INF/src/test/webapp/WEB-INF

中的位置

3 个答案:

答案 0 :(得分:1)

创建ShrinkWrap存档时必须使用addAsWebInfResource(new File("src/main/webapp/WEB-INF/appengine-web.xml"))

您可能希望看到WebContainer API

答案 1 :(得分:1)

默认情况下,src/main/webapp中的文件不适用于测试类加载器。解决方案是将* web.xml放在src/main/resources中,并在组装最终工件时将文件放在预期的目标位置。

答案 2 :(得分:0)

看起来你没有将appengine-web.xml文件打包到ShrinkWrap的档案中。