我試圖運行Google pubsub java示例 - appengine在本地開發服務器上通過參考this指南推送。Github - Google pubsub java示例 - Maven測試運行失敗
$ gcloud config set project <provided-my-application-id>
$ mvn gcloud:run
Maven構建成功,但測試運行失敗。以下是執行。如何解決這個問題?
E:\java\cloud-pubsub-samples-java-master\appengine-push>mvn gcloud:run
[INFO] Scanning for projects...
[WARNING] The POM for com.google.appengine:appengine-maven-plugin:jar:2.0.9.121.v20160815 is missing, no dependency information available
[WARNING] Failed to retrieve plugin descriptor for com.google.appengine:appengine-maven-plugin:2.0.9.121.v20160815: Plugin com.google.appengine:appengine-maven-plugin:2.0.9.121.v20160815 or one of its dependencies could not be resolved: Failure to find com.google.appengine:appengine-maven-plugin:jar:2.0.9.121.v20160815 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Example for the Google Cloud Pub/Sub on Google App Engine. 1
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.google.appengine:appengine-maven-plugin:jar:2.0.9.121.v20160815 is missing, no dependency information available
[WARNING] Failed to retrieve plugin descriptor for com.google.appengine:appengine-maven-plugin:2.0.9.121.v20160815: Plugin com.google.appengine:appengine-maven-plugin:2.0.9.121.v20160815 or one of its dependencies could not be resolved: Failure to find com.google.appengine:appengine-maven-plugin:jar:2.0.9.121.v20160815 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
[INFO]
[INFO] >>> gcloud-maven-plugin:2.0.9.90.v20151210:run (default-cli) > package @ pubsub-appengine-sample >>>
[INFO]
[INFO] --- maven-checkstyle-plugin:2.15:check (validate) @ pubsub-appengine-sample ---
[INFO] Starting audit...
Audit done.
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ pubsub-appengine-sample ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory E:\java\cloud-pubsub-samples-java-master\appengine-push\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ pubsub-appengine-sample ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 10 source files to E:\java\cloud-pubsub-samples-java-master\appengine-push\target\war\WEB-INF\classes
[INFO]
[INFO] --- versions-maven-plugin:2.2:display-dependency-updates (default) @ pubsub-appengine-sample ---
[INFO] artifact com.google.api-client:google-api-client-appengine: checking for updates from central
[INFO] artifact com.google.appengine:appengine-api-1.0-sdk: checking for updates from central
[INFO] artifact junit:junit: checking for updates from central
[INFO] artifact org.codehaus.jackson:jackson-mapper-asl: checking for updates from central
[INFO] artifact com.google.apis:google-api-services-pubsub: checking for updates from central
[INFO] artifact org.mockito:mockito-all: checking for updates from central
[INFO] The following dependencies in Dependencies have newer versions:
[INFO] com.google.api-client:google-api-client-appengine ... 1.21.0 -> 1.22.0
[INFO] com.google.apis:google-api-services-pubsub ...
[INFO] v1-rev8-1.21.0 -> v1-rev11-1.22.0
[INFO] com.google.appengine:appengine-api-1.0-sdk .......... 1.9.31 -> 1.9.42
[INFO] org.mockito:mockito-all ........................ 1.10.19 -> 2.0.2-beta
[INFO]
[INFO]
[INFO] --- versions-maven-plugin:2.2:display-plugin-updates (default) @ pubsub-appengine-sample ---
[INFO]
[INFO] The following plugin updates are available:
[INFO] com.google.appengine:gcloud-maven-plugin 2.0.9.90.v20151210 -> 2.0.9.121.v20160815
[INFO] maven-checkstyle-plugin ................................ 2.15 -> 2.17
[INFO] maven-compiler-plugin .................................. 3.3 -> 3.5.1
[INFO] org.codehaus.mojo:findbugs-maven-plugin .............. 3.0.3 -> 3.0.4
[INFO] org.codehaus.mojo:versions-maven-plugin .................. 2.2 -> 2.3
[INFO]
[WARNING] The following plugins do not have their version specified:
[WARNING] maven-clean-plugin ........................ (from super-pom) 3.0.0
[WARNING] maven-deploy-plugin ....................... (from super-pom) 2.8.2
[WARNING] maven-install-plugin ...................... (from super-pom) 2.5.2
[WARNING] maven-resources-plugin .................... (from super-pom) 3.0.1
[WARNING] maven-site-plugin ......................... (from super-pom) 3.5.1
[WARNING] maven-surefire-plugin .................... (from super-pom) 2.19.1
[INFO]
[INFO] Project defines minimum Maven version as: 3.1.0
[INFO] Plugins require minimum Maven version of: 3.1.0
[INFO] Note: the super-pom from Maven 3.3.9 defines some of the plugin
[INFO] versions and may be influencing the plugins required minimum Maven
[INFO] version.
[INFO]
[INFO] No plugins require a newer version of Maven than specified by the pom.
[INFO]
[INFO]
[INFO] --- maven-war-plugin:2.6:exploded (default) @ pubsub-appengine-sample ---
[INFO] Exploding webapp
[INFO] Assembling webapp [pubsub-appengine-sample] in [E:\java\cloud-pubsub-samples-java-master\appengine-push\target\war]
[INFO] Processing war project
[INFO] Copying webapp resources [E:\java\cloud-pubsub-samples-java-master\appengine-push\src\main\webapp]
[INFO] Webapp assembled in [859 msecs]
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ pubsub-appengine-sample ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory E:\java\cloud-pubsub-samples-java-master\appengine-push\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.3:testCompile (default-testCompile) @ pubsub-appengine-sample ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ pubsub-appengine-sample ---
[INFO] Surefire report directory: E:\java\cloud-pubsub-samples-java-master\appengine-push\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.google.cloud.pubsub.client.demos.appengine.IntegrationTest
Tests run: 3, Failures: 3, Errors: 0, Skipped: 0, Time elapsed: 2.351 sec <<< FAILURE!
testTopPage(com.google.cloud.pubsub.client.demos.appengine.IntegrationTest) Time elapsed: 1.442 sec <<< FAILURE!
java.lang.AssertionError: expected:<200> but was:<404>
at org.junit.Assert.fail(Assert.java:88)
at org.junit.Assert.failNotEquals(Assert.java:834)
at org.junit.Assert.assertEquals(Assert.java:645)
at org.junit.Assert.assertEquals(Assert.java:631)
at com.google.cloud.pubsub.client.demos.appengine.IntegrationTest.testTopPage(IntegrationTest.java:72)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
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:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
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)
testSendMessage(com.google.cloud.pubsub.client.demos.appengine.IntegrationTest) Time elapsed: 0.369 sec <<< FAILURE!
java.lang.AssertionError: expected:<204> but was:<404>
at org.junit.Assert.fail(Assert.java:88)
at org.junit.Assert.failNotEquals(Assert.java:834)
at org.junit.Assert.assertEquals(Assert.java:645)
at org.junit.Assert.assertEquals(Assert.java:631)
at com.google.cloud.pubsub.client.demos.appengine.IntegrationTest.testSendMessage(IntegrationTest.java:151)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
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:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
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)
testPushHandlerIsProtected(com.google.cloud.pubsub.client.demos.appengine.IntegrationTest) Time elapsed: 0.336 sec <<< FAILURE!
java.lang.AssertionError: expected:<302> but was:<404>
at org.junit.Assert.fail(Assert.java:88)
at org.junit.Assert.failNotEquals(Assert.java:834)
at org.junit.Assert.assertEquals(Assert.java:645)
at org.junit.Assert.assertEquals(Assert.java:631)
at com.google.cloud.pubsub.client.demos.appengine.IntegrationTest.testPushHandlerIsProtected(IntegrationTest.java:128)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
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:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
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)
Results :
Failed tests: testTopPage(com.google.cloud.pubsub.client.demos.appengine.IntegrationTest): expected:<200> but was:<404>
testSendMessage(com.google.cloud.pubsub.client.demos.appengine.IntegrationTest): expected:<204> but was:<404>
testPushHandlerIsProtected(com.google.cloud.pubsub.client.demos.appengine.IntegrationTest): expected:<302> but was:<404>
Tests run: 3, Failures: 3, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 23.681 s
[INFO] Finished at: 2016-08-29T08:28:48+05:30
[INFO] Final Memory: 31M/333M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire- plugin:2.12.4:test (default-test) on project pubsub-appengine-sample: There are test failures.
[ERROR]
[ERROR] Please refer to E:\java\cloud-pubsub-samples-java-master\appengine-push\target\surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
更新 - 試運行失敗意見: 我的意見是, 對於testTopPage() - 72號線通過的響應是200元。但在線路84失敗,因爲內容沒有我的項目_id。對於testSendMessage() - 在第133行失敗並出現404錯誤,url = getAppBaseURL()+「send_message」;因爲沒有這樣的資源。
同樣,testPushHandlerIsProtected() - 由於沒有這樣的資源而在第110行出現404錯誤。
注意:我的項目在appengine中只有hello world應用程序,但這些測試方法正在尋找appengine中不存在的資源。我錯過了什麼?
您必須在appengine上部署示例應用程序才能使測試正常工作(請參閱編輯我的答案)。 – konqi