You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*[Contributing a new sample](#Contributing-a-new-sample)
4
+
*[Contributing a Patch or New Sample](#Contributing-a-Patch)
6
5
*[Build Tools](#build-tools)
7
6
*[Integration Testing](#testing)
8
7
*[Style](#Style)
@@ -26,32 +25,37 @@ Follow either of the two links above to access the appropriate CLA and
26
25
instructions for how to sign and return it. Once we receive it, we'll be able to
27
26
accept your pull requests.
28
27
29
-
## Contributing a Patch
28
+
## Contributing a Patch or New Sample
30
29
31
-
1. Submit an issue describing your proposed change to the repo in question.
32
-
1. The repo owner will respond to your issue promptly.
33
-
1. If your proposed change is accepted, and you haven't already done so, sign a
34
-
Contributor License Agreement (see details above).
35
-
1. Fork the desired repo, develop and test your code changes.
36
-
1. Ensure that your code adheres to the existing style in the sample to which
37
-
you are contributing.
30
+
1. Sign a [Contributor License Agreement](#Contributor-License-Agreements).
31
+
1. Set up your [Java Developer Environment](https://cloud.google.com/java/docs/setup).
32
+
1. Fork the repo.
33
+
1. Develop and test your code.
34
+
1. Ensure that your code adheres to the [SAMPLE_FORMAT.md](SAMPLE_FORMAT.md)
35
+
guidelines.
38
36
1. Ensure that your code has an appropriate set of unit tests which all pass.
39
37
1. Submit a pull request.
38
+
1. A maintainer will review the pull request and make comments.
40
39
41
-
## Contributing a new sample
40
+
## Build Tools
42
41
43
-
1. See the [SAMPLE_FORMAT.md](SAMPLE_FORMAT.md) for guidelines on the preferred sample format.
42
+
All new samples should build and run integration tests with both [Maven](https://maven.apache.org/) and [Gradle](https://gradle.org/).
44
43
44
+
## Integration Testing
45
45
46
-
## Build Tools
46
+
All samples must have Integration Tests that run with Maven and Gradle
47
47
48
-
For instructions regarding development environment setup, please visit [the documentation](https://cloud.google.com/java/docs/setup). All new samples should build and run integration tests with both [Maven](https://maven.apache.org/) and [Gradle](https://gradle.org/).
48
+
* Test Library: [JUnit4](https://junit.org/junit4/)
49
+
* Test Runner: [Maven Failsafe plugin](https://maven.apache.org/surefire/maven-failsafe-plugin/) and [Maven Surefire plugin](https://maven.apache.org/surefire/maven-surefire-plugin/).
49
50
50
-
##Testing
51
+
### Running Tests Locally
51
52
52
-
All samples must have Integration Tests (ie. They need to run against a real service) that run with
53
-
`mvn verify` & `gradle build test`. If we need to enable an API, let us know.
53
+
Run tests locally with commands:
54
+
* Maven: `mvn verify`
55
+
* Gradle: `gradle build test`
54
56
57
+
58
+
### Gradle Specifcs
55
59
Your `build.gradle` should have the following section:
56
60
57
61
```groovy
@@ -72,9 +76,34 @@ test {
72
76
}
73
77
```
74
78
75
-
### Keys and Secrets
79
+
### Other Testing Set Up
80
+
81
+
Most samples require a GCP project and billing account. Keep the following in
82
+
mind when setting up tests.
83
+
84
+
***Environment variables**
85
+
Minimize additional environment variables that need to be set to run the tests.
86
+
If you do require additional environment variables, they should be added to
87
+
`run_tests.sh`.
88
+
89
+
Existing environment variables include:
90
+
*`GOOGLE_APPLICATION_CREDENTIALS`
91
+
*`GOOGLE_CLOUD_PROJECT`
92
+
*`PROJECT_ID`
93
+
94
+
95
+
***API library**
96
+
Add a note in the pull request, if an API needs to be enable in the testing
97
+
project.
76
98
77
-
Please contact a Java DPE for instructions before adding to Travis.
99
+
***Cloud resources**
100
+
Most Java samples create the Cloud resources that they need to run. If this
101
+
is resource intensive or not possible, add a note in the pull request for the
102
+
resource to be added to the testing project.
103
+
104
+
***Keys and Secrets**
105
+
Add a note in the pull request, in order for a Java maintainer to assist you
106
+
in adding keys and secrets to the testing project.
<imgalt="Open in Cloud Shell"src ="http://gstatic.com/cloudssh/images/open-btn.png"></a>
8
8
9
-
While this library is still supported, we suggest trying the newer [Cloud Client Library](https://developers.google.com/api-client-library/java/apis/vision/v1) for Google Cloud Vision, especially for new projects. For more information, please see the notice on the [API Client Library Page](https://developers.google.com/api-client-library/java/apis/vision/v1).
9
+
This repository holds sample code written in Go that demonstrates the
You can override this behavior using setCredentials in `BigQueryOptions.newBuilder()` by adding `setCredentials(Credentials credentials)` from [ServiceOptions.builder](http://googlecloudplatform.github.io/google-cloud-java/0.12.0/apidocs/com/google/cloud/ServiceOptions.Builder.html#setCredentials-com.google.auth.Credentials-) and [Credentials](http://google.github.io/google-auth-library-java/releases/0.6.0/apidocs/com/google/auth/Credentials.html?is-external=true).
30
+
Or manually set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable
31
+
to point to a service account key JSON file path.
32
+
33
+
Learn more at [Setting Up Authentication for Server to Server Production Applications](ADC).
34
+
35
+
*Note:* Application Default Credentials is able to implicitly find the credentials as long as the application is running on Compute Engine, Kubernetes Engine, App Engine, or Cloud Functions.
0 commit comments