Github - Google pubsub java samples - Maven test run failure

8 views
Skip to first unread message

Vetri via StackOverflow

unread,
Aug 29, 2016, 5:13:07 AM8/29/16
to google-appengin...@googlegroups.com

I'm trying to run Google pubsub java samples - appengine push on local development server by referring this guide.

$ gcloud config set project <provided-my-application-id>
$ mvn gcloud:run

Maven build is successful but test run failed. Below is execution. How to resolve this?

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


Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/39202438/github-google-pubsub-java-samples-maven-test-run-failure

konqi via StackOverflow

unread,
Aug 29, 2016, 7:58:04 AM8/29/16
to google-appengin...@googlegroups.com

Have a look at line 31 in the test. It uses a different environment variable called 'TEST_PROJECT_ID' (see line 24). It should be as simple as setting the correct environment variable. You could also add a debug output for the URL in the unit test so you know what hostname is used.



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/39202438/github-google-pubsub-java-samples-maven-test-run-failure/39205654#39205654

Vetri via StackOverflow

unread,
Aug 29, 2016, 3:33:04 PM8/29/16
to google-appengin...@googlegroups.com

Updated - Test run failure observations: My observations are, For testTopPage() - Line 72 passed as the response is 200. But fails at line 84 because contents do not have my project _id.

For testSendMessage() - fails with 404 error at line 133, url = getAppBaseURL() + "send_message"; as there is no such resource.

Similarly,testPushHandlerIsProtected()- fails with 404 error at line 110 as there no such resource.

Note: My project has only hello world application in appengine but these test methods are looking for resource that is not present in appengine. What am I missing?

konqi via StackOverflow

unread,
Aug 30, 2016, 3:18:07 AM8/30/16
to google-appengin...@googlegroups.com

Have a look at line 31 in the test. It uses a different environment variable called 'TEST_PROJECT_ID' (see line 24). It should be as simple as setting the correct environment variable. You could also add a debug output for the URL in the unit test so you know what hostname is used.

Edit1: What do you mean, you only have a hello world application in appengine? The 'send_message' resource and the init_servlet, which returns the project id as asserted by line 84 are defined in the web.xml of the sample. You will have to deploy this application before you run the tests against it (or find an instance of this app that is already running). If you can't deploy the app because your tests are failing, you can skip surefire tests by adding the -DskipTests parameter to your maven command. This is also explained in the readme of the project.



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/39202438/github-google-pubsub-java-samples-maven-test-run-failure/39205654#39205654
Reply all
Reply to author
Forward
0 new messages