├── .github ├── .release-please.yml ├── CODEOWNERS ├── ISSUE_TEMPLATE.md ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── feature_request.md │ └── support_request.md ├── PULL_REQUEST_TEMPLATE.md ├── auto-label.yaml ├── blunderbuss.yml ├── dependabot.yml ├── release-please.yml ├── release-trigger.yml ├── snippet-bot.yml ├── sync-repo-settings.yaml ├── trusted-contribution.yml └── workflows │ ├── approve-readme.yaml │ ├── auto-release.yaml │ ├── ci-java7.yaml │ ├── ci.yaml │ ├── downstream.yaml │ ├── renovate_config_check.yaml │ └── scorecard.yml ├── .gitignore ├── .kokoro ├── build.bat ├── build.sh ├── coerce_logs.sh ├── common.cfg ├── common.sh ├── continuous │ ├── common.cfg │ ├── java10.cfg │ ├── java8.cfg │ └── propose_release.sh ├── dependencies.sh ├── downstream-client-library-check.sh ├── nightly │ ├── common.cfg │ ├── integration.cfg │ ├── java11-integration.cfg │ ├── java11.cfg │ ├── java7.cfg │ ├── java8-osx.cfg │ ├── java8-win.cfg │ ├── java8.cfg │ └── samples.cfg ├── populate-secrets.sh ├── presubmit │ ├── clirr.cfg │ ├── common.cfg │ ├── dependencies.cfg │ ├── graalvm-native-a.cfg │ ├── graalvm-native-b.cfg │ ├── graalvm-native-c.cfg │ ├── integration.cfg │ ├── java10.cfg │ ├── java11.cfg │ ├── java7.cfg │ ├── java8-osx.cfg │ ├── java8-win.cfg │ ├── java8.cfg │ ├── linkage-monitor.cfg │ ├── lint.cfg │ └── samples.cfg ├── readme.sh └── trampoline.sh ├── .repo-metadata.json ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── SECURITY.md ├── checkstyle-suppressions.xml ├── checkstyle.xml ├── docs ├── _config.yml ├── _data │ └── navigation.yml ├── _layouts │ └── default.html ├── android.md ├── component-modules.md ├── exponential-backoff.md ├── google-app-engine.md ├── http-transport.md ├── index.md ├── json.md ├── setup.md ├── support.md └── unit-testing.md ├── findbugs-exclude.xml ├── google-http-client-android-test ├── AndroidManifest.xml ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── google │ └── api │ └── client │ └── extensions │ └── android │ └── json │ ├── AndroidJsonFactoryTest.java │ ├── FakeTest.java │ └── package-info.java ├── google-http-client-android ├── AndroidManifest.xml ├── pom.xml ├── project.properties └── src │ └── main │ └── java │ └── com │ └── google │ └── api │ └── client │ └── extensions │ └── android │ ├── AndroidUtils.java │ ├── http │ ├── AndroidHttp.java │ └── package-info.java │ ├── json │ ├── AndroidJsonFactory.java │ ├── AndroidJsonGenerator.java │ ├── AndroidJsonParser.java │ └── package-info.java │ ├── package-info.java │ └── util │ └── store │ └── FileDataStoreFactory.java ├── google-http-client-apache-v2 ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── google │ │ │ └── api │ │ │ └── client │ │ │ └── http │ │ │ └── apache │ │ │ └── v2 │ │ │ ├── ApacheHttpRequest.java │ │ │ ├── ApacheHttpResponse.java │ │ │ ├── ApacheHttpTransport.java │ │ │ ├── ContentEntity.java │ │ │ ├── HttpExtensionMethod.java │ │ │ └── package-info.java │ └── resources │ │ └── META-INF │ │ └── native-image │ │ └── com.google.http-client │ │ └── google-http-client-apache-v2 │ │ └── reflect-config.json │ └── test │ └── java │ └── com │ └── google │ └── api │ └── client │ └── http │ └── apache │ └── v2 │ ├── ApacheHttpRequestTest.java │ └── ApacheHttpTransportTest.java ├── google-http-client-apache-v5 ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── google │ │ └── api │ │ └── client │ │ └── http │ │ └── apache │ │ └── v5 │ │ ├── Apache5ContentEntity.java │ │ ├── Apache5HttpRequest.java │ │ ├── Apache5HttpResponse.java │ │ ├── Apache5HttpTransport.java │ │ ├── Apache5ResponseContent.java │ │ └── package-info.java │ └── test │ └── java │ └── com │ └── google │ └── api │ └── client │ └── http │ └── apache │ └── v5 │ ├── Apache5HttpRequestTest.java │ ├── Apache5HttpResponseTest.java │ ├── Apache5HttpTransportTest.java │ ├── Apache5ResponseContentTest.java │ ├── MockClassicHttpResponse.java │ └── MockHttpClient.java ├── google-http-client-appengine ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── google │ │ │ └── api │ │ │ └── client │ │ │ └── extensions │ │ │ └── appengine │ │ │ ├── datastore │ │ │ ├── AppEngineDataStoreFactory.java │ │ │ └── package-info.java │ │ │ └── http │ │ │ ├── UrlFetchRequest.java │ │ │ ├── UrlFetchResponse.java │ │ │ ├── UrlFetchTransport.java │ │ │ └── package-info.java │ └── resources │ │ └── META-INF │ │ └── native-image │ │ └── com.google.http-client │ │ └── google-http-client-appengine │ │ └── reflect-config.json │ └── test │ ├── java │ └── com │ │ └── google │ │ └── api │ │ └── client │ │ └── extensions │ │ └── appengine │ │ ├── datastore │ │ ├── AppEngineDataStoreFactoryTest.java │ │ └── AppEngineNoMemcacheDataStoreFactoryTest.java │ │ └── http │ │ └── UrlFetchTransportTest.java │ └── resources │ └── META-INF │ └── native-image │ └── com.google.http-client │ └── google-http-client-appengine │ └── native-image.properties ├── google-http-client-assembly ├── LICENSE.txt ├── assembly.xml ├── classpath-include ├── licenses │ ├── APACHE-LICENSE.txt │ ├── BSD-LICENSE.txt │ ├── CDDL-LICENSE.txt │ └── xpp3_LICENSE.txt ├── pom.xml ├── proguard-google-http-client.txt ├── properties │ ├── google-http-client-android.jar.properties │ ├── google-http-client-apache-v2.jar.properties │ ├── google-http-client-gson.jar.properties │ ├── google-http-client-jackson2.jar.properties │ ├── google-http-client-protobuf.jar.properties │ ├── google-http-client-xml.jar.properties │ ├── google-http-client.jar.properties │ ├── gson.jar.properties │ ├── jackson-core.jar.properties │ └── protobuf-java.jar.properties └── readme.html ├── google-http-client-bom ├── README.md └── pom.xml ├── google-http-client-findbugs ├── google-http-client-findbugs-test │ ├── .classpath │ ├── .project │ ├── .settings │ │ ├── org.eclipse.jdt.core.prefs │ │ └── org.eclipse.jdt.ui.prefs │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── google │ │ └── api │ │ └── client │ │ └── findbugs │ │ └── test │ │ ├── BetaClass.java │ │ ├── BetaClass2.java │ │ ├── ClassWithBetaField.java │ │ ├── ClassWithBetaMethod.java │ │ └── Test.java ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── google │ │ └── api │ │ └── client │ │ └── findbugs │ │ ├── BetaDetector.java │ │ └── package-info.java │ └── resources │ ├── bugrank.txt │ ├── findbugs.xml │ └── messages.xml ├── google-http-client-gson ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── google │ │ │ └── api │ │ │ └── client │ │ │ └── json │ │ │ └── gson │ │ │ ├── GsonFactory.java │ │ │ ├── GsonGenerator.java │ │ │ ├── GsonParser.java │ │ │ └── package-info.java │ └── resources │ │ └── META-INF │ │ └── native-image │ │ └── com.google.http-client │ │ └── google-http-client-gson │ │ └── reflect-config.json │ └── test │ ├── java │ └── com │ │ └── google │ │ └── api │ │ └── client │ │ └── json │ │ └── gson │ │ ├── GsonFactoryTest.java │ │ ├── GsonGeneratorTest.java │ │ └── GsonParserTest.java │ └── resources │ └── META-INF │ └── native-image │ └── com.google.http-client │ └── google-http-client-gson │ └── native-image.properties ├── google-http-client-jackson2 ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── google │ │ │ └── api │ │ │ └── client │ │ │ └── json │ │ │ └── jackson2 │ │ │ ├── JacksonFactory.java │ │ │ ├── JacksonGenerator.java │ │ │ ├── JacksonParser.java │ │ │ └── package-info.java │ └── resources │ │ └── META-INF │ │ └── native-image │ │ └── com.google.http-client │ │ └── google-http-client-jackson2 │ │ └── reflect-config.json │ └── test │ ├── java │ └── com │ │ └── google │ │ └── api │ │ └── client │ │ └── json │ │ └── jackson2 │ │ ├── JacksonFactoryTest.java │ │ ├── JacksonGeneratorTest.java │ │ └── JacksonParserTest.java │ └── resources │ └── META-INF │ └── native-image │ └── com.google.http-client │ └── google-http-client-jackson2 │ └── native-image.properties ├── google-http-client-protobuf ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── google │ │ │ └── api │ │ │ └── client │ │ │ ├── http │ │ │ └── protobuf │ │ │ │ ├── ProtoHttpContent.java │ │ │ │ └── package-info.java │ │ │ └── protobuf │ │ │ ├── ProtoObjectParser.java │ │ │ ├── ProtocolBuffers.java │ │ │ └── package-info.java │ └── resources │ │ └── META-INF │ │ └── native-image │ │ └── com.google.http-client │ │ └── google-http-client-protobuf │ │ ├── native-image.properties │ │ └── reflect-config.json │ └── test │ ├── java │ └── com │ │ └── google │ │ └── api │ │ └── client │ │ └── protobuf │ │ └── ProtocolBuffersTest.java │ └── proto │ └── simple_proto.proto ├── google-http-client-test ├── clirr-ignored-differences.xml ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── google │ │ │ └── api │ │ │ └── client │ │ │ └── test │ │ │ ├── json │ │ │ ├── AbstractJsonFactoryTest.java │ │ │ ├── AbstractJsonGeneratorTest.java │ │ │ ├── AbstractJsonParserTest.java │ │ │ └── package-info.java │ │ │ └── util │ │ │ └── store │ │ │ ├── AbstractDataStoreFactoryTest.java │ │ │ └── package-info.java │ └── resources │ │ └── META-INF │ │ └── native-image │ │ └── com.google.http-client │ │ └── google-http-client-test │ │ ├── native-image.properties │ │ ├── reflect-config.json │ │ └── serialization-config.json │ └── test │ └── java │ └── com │ └── google │ └── api │ └── client │ └── test │ └── util │ └── store │ ├── FileDataStoreFactoryTest.java │ └── MemoryDataStoreFactoryTest.java ├── google-http-client-xml ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── google │ │ │ └── api │ │ │ └── client │ │ │ ├── http │ │ │ └── xml │ │ │ │ ├── AbstractXmlHttpContent.java │ │ │ │ ├── XmlHttpContent.java │ │ │ │ ├── atom │ │ │ │ ├── AtomContent.java │ │ │ │ ├── AtomFeedParser.java │ │ │ │ └── package-info.java │ │ │ │ └── package-info.java │ │ │ └── xml │ │ │ ├── GenericXml.java │ │ │ ├── Xml.java │ │ │ ├── XmlNamespaceDictionary.java │ │ │ ├── XmlObjectParser.java │ │ │ ├── atom │ │ │ ├── AbstractAtomFeedParser.java │ │ │ ├── Atom.java │ │ │ └── package-info.java │ │ │ └── package-info.java │ └── resources │ │ └── META-INF │ │ └── native-image │ │ └── com.google.http-client │ │ └── google-http-client-xml │ │ └── reflect-config.json │ └── test │ ├── java │ └── com │ │ └── google │ │ └── api │ │ └── client │ │ └── xml │ │ ├── AtomTest.java │ │ ├── GenericXmlListTest.java │ │ ├── GenericXmlTest.java │ │ ├── XmlEnumTest.java │ │ ├── XmlListTest.java │ │ ├── XmlNamespaceDictionaryTest.java │ │ └── XmlTest.java │ └── resources │ ├── META-INF │ └── native-image │ │ └── com.google.http-client │ │ └── google-http-client-xml │ │ ├── native-image.properties │ │ ├── reflect-config.json │ │ └── resource-config.json │ └── sample-atom.xml ├── google-http-client ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── google │ │ │ └── api │ │ │ └── client │ │ │ ├── http │ │ │ ├── AbstractHttpContent.java │ │ │ ├── AbstractInputStreamContent.java │ │ │ ├── BackOffPolicy.java │ │ │ ├── BasicAuthentication.java │ │ │ ├── ByteArrayContent.java │ │ │ ├── ConsumingInputStream.java │ │ │ ├── EmptyContent.java │ │ │ ├── ExponentialBackOffPolicy.java │ │ │ ├── FileContent.java │ │ │ ├── GZipEncoding.java │ │ │ ├── GenericUrl.java │ │ │ ├── GzipSupport.java │ │ │ ├── HttpBackOffIOExceptionHandler.java │ │ │ ├── HttpBackOffUnsuccessfulResponseHandler.java │ │ │ ├── HttpContent.java │ │ │ ├── HttpEncoding.java │ │ │ ├── HttpEncodingStreamingContent.java │ │ │ ├── HttpExecuteInterceptor.java │ │ │ ├── HttpHeaders.java │ │ │ ├── HttpIOExceptionHandler.java │ │ │ ├── HttpMediaType.java │ │ │ ├── HttpMethods.java │ │ │ ├── HttpRequest.java │ │ │ ├── HttpRequestFactory.java │ │ │ ├── HttpRequestInitializer.java │ │ │ ├── HttpResponse.java │ │ │ ├── HttpResponseException.java │ │ │ ├── HttpResponseInterceptor.java │ │ │ ├── HttpStatusCodes.java │ │ │ ├── HttpTransport.java │ │ │ ├── HttpUnsuccessfulResponseHandler.java │ │ │ ├── InputStreamContent.java │ │ │ ├── LowLevelHttpRequest.java │ │ │ ├── LowLevelHttpResponse.java │ │ │ ├── MultipartContent.java │ │ │ ├── OpenCensusUtils.java │ │ │ ├── UriTemplate.java │ │ │ ├── UrlEncodedContent.java │ │ │ ├── UrlEncodedParser.java │ │ │ ├── apache │ │ │ │ ├── ApacheHttpRequest.java │ │ │ │ ├── ApacheHttpResponse.java │ │ │ │ ├── ApacheHttpTransport.java │ │ │ │ ├── ContentEntity.java │ │ │ │ ├── HttpExtensionMethod.java │ │ │ │ ├── SSLSocketFactoryExtension.java │ │ │ │ └── package-info.java │ │ │ ├── javanet │ │ │ │ ├── ConnectionFactory.java │ │ │ │ ├── DefaultConnectionFactory.java │ │ │ │ ├── NetHttpRequest.java │ │ │ │ ├── NetHttpResponse.java │ │ │ │ ├── NetHttpTransport.java │ │ │ │ └── package-info.java │ │ │ ├── json │ │ │ │ ├── JsonHttpContent.java │ │ │ │ └── package-info.java │ │ │ └── package-info.java │ │ │ ├── json │ │ │ ├── CustomizeJsonParser.java │ │ │ ├── GenericJson.java │ │ │ ├── Json.java │ │ │ ├── JsonFactory.java │ │ │ ├── JsonGenerator.java │ │ │ ├── JsonObjectParser.java │ │ │ ├── JsonParser.java │ │ │ ├── JsonPolymorphicTypeMap.java │ │ │ ├── JsonString.java │ │ │ ├── JsonToken.java │ │ │ ├── package-info.java │ │ │ ├── rpc2 │ │ │ │ ├── JsonRpcRequest.java │ │ │ │ └── package-info.java │ │ │ └── webtoken │ │ │ │ ├── DerEncoder.java │ │ │ │ ├── JsonWebSignature.java │ │ │ │ ├── JsonWebToken.java │ │ │ │ └── package-info.java │ │ │ ├── testing │ │ │ ├── http │ │ │ │ ├── FixedClock.java │ │ │ │ ├── HttpTesting.java │ │ │ │ ├── MockHttpContent.java │ │ │ │ ├── MockHttpTransport.java │ │ │ │ ├── MockHttpUnsuccessfulResponseHandler.java │ │ │ │ ├── MockLowLevelHttpRequest.java │ │ │ │ ├── MockLowLevelHttpResponse.java │ │ │ │ ├── apache │ │ │ │ │ ├── MockHttpClient.java │ │ │ │ │ └── package-info.java │ │ │ │ ├── javanet │ │ │ │ │ ├── MockHttpURLConnection.java │ │ │ │ │ └── package-info.java │ │ │ │ └── package-info.java │ │ │ ├── json │ │ │ │ ├── MockJsonFactory.java │ │ │ │ ├── MockJsonGenerator.java │ │ │ │ ├── MockJsonParser.java │ │ │ │ ├── package-info.java │ │ │ │ └── webtoken │ │ │ │ │ ├── TestCertificates.java │ │ │ │ │ └── package-info.java │ │ │ └── util │ │ │ │ ├── LogRecordingHandler.java │ │ │ │ ├── MockBackOff.java │ │ │ │ ├── MockSleeper.java │ │ │ │ ├── SecurityTestUtils.java │ │ │ │ ├── TestableByteArrayInputStream.java │ │ │ │ ├── TestableByteArrayOutputStream.java │ │ │ │ └── package-info.java │ │ │ └── util │ │ │ ├── ArrayMap.java │ │ │ ├── ArrayValueMap.java │ │ │ ├── BackOff.java │ │ │ ├── BackOffUtils.java │ │ │ ├── Base64.java │ │ │ ├── Beta.java │ │ │ ├── ByteArrayStreamingContent.java │ │ │ ├── ByteCountingOutputStream.java │ │ │ ├── ByteStreams.java │ │ │ ├── Charsets.java │ │ │ ├── ClassInfo.java │ │ │ ├── Clock.java │ │ │ ├── Collections2.java │ │ │ ├── Data.java │ │ │ ├── DataMap.java │ │ │ ├── DateTime.java │ │ │ ├── ExponentialBackOff.java │ │ │ ├── FieldInfo.java │ │ │ ├── GenericData.java │ │ │ ├── IOUtils.java │ │ │ ├── Joiner.java │ │ │ ├── Key.java │ │ │ ├── Lists.java │ │ │ ├── LoggingByteArrayOutputStream.java │ │ │ ├── LoggingInputStream.java │ │ │ ├── LoggingOutputStream.java │ │ │ ├── LoggingStreamingContent.java │ │ │ ├── Maps.java │ │ │ ├── NanoClock.java │ │ │ ├── NullValue.java │ │ │ ├── ObjectParser.java │ │ │ ├── Objects.java │ │ │ ├── PemReader.java │ │ │ ├── Preconditions.java │ │ │ ├── SecurityUtils.java │ │ │ ├── Sets.java │ │ │ ├── Sleeper.java │ │ │ ├── SslUtils.java │ │ │ ├── StreamingContent.java │ │ │ ├── StringUtils.java │ │ │ ├── Strings.java │ │ │ ├── Throwables.java │ │ │ ├── Types.java │ │ │ ├── Value.java │ │ │ ├── escape │ │ │ ├── CharEscapers.java │ │ │ ├── Escaper.java │ │ │ ├── PercentEscaper.java │ │ │ ├── Platform.java │ │ │ ├── UnicodeEscaper.java │ │ │ └── package-info.java │ │ │ ├── package-info.java │ │ │ └── store │ │ │ ├── AbstractDataStore.java │ │ │ ├── AbstractDataStoreFactory.java │ │ │ ├── AbstractMemoryDataStore.java │ │ │ ├── DataStore.java │ │ │ ├── DataStoreFactory.java │ │ │ ├── DataStoreUtils.java │ │ │ ├── FileDataStoreFactory.java │ │ │ ├── MemoryDataStoreFactory.java │ │ │ └── package-info.java │ └── resources │ │ ├── META-INF │ │ └── native-image │ │ │ └── com.google.http-client │ │ │ └── google-http-client │ │ │ ├── native-image.properties │ │ │ ├── reflect-config.json │ │ │ ├── resource-config.json │ │ │ └── serialization-config.json │ │ └── com │ │ └── google │ │ └── api │ │ └── client │ │ └── http │ │ └── google-http-client.properties │ └── test │ ├── java │ └── com │ │ └── google │ │ └── api │ │ └── client │ │ ├── http │ │ ├── AbstractHttpContentTest.java │ │ ├── BasicAuthenticationTest.java │ │ ├── ByteArrayContentTest.java │ │ ├── ConsumingInputStreamTest.java │ │ ├── EmptyContentTest.java │ │ ├── ExponentialBackOffPolicyTest.java │ │ ├── GZipEncodingTest.java │ │ ├── GenericUrlTest.java │ │ ├── GzipSupportTest.java │ │ ├── HttpBackOffIOExpcetionHandlerTest.java │ │ ├── HttpBackOffUnsuccessfulResponseHandlerTest.java │ │ ├── HttpEncodingStreamingContentTest.java │ │ ├── HttpHeadersTest.java │ │ ├── HttpMediaTypeTest.java │ │ ├── HttpRequestFactoryTest.java │ │ ├── HttpRequestTest.java │ │ ├── HttpRequestTracingTest.java │ │ ├── HttpResponseExceptionTest.java │ │ ├── HttpResponseTest.java │ │ ├── HttpStatusCodesTest.java │ │ ├── MultipartContentTest.java │ │ ├── OpenCensusUtilsTest.java │ │ ├── UriTemplateTest.java │ │ ├── UrlEncodedContentTest.java │ │ ├── UrlEncodedParserTest.java │ │ └── javanet │ │ │ ├── NetHttpRequestTest.java │ │ │ ├── NetHttpResponseTest.java │ │ │ └── NetHttpTransportTest.java │ │ ├── json │ │ ├── GenericJsonTest.java │ │ ├── JsonObjectParserTest.java │ │ ├── JsonParserTest.java │ │ └── webtoken │ │ │ └── JsonWebSignatureTest.java │ │ ├── testing │ │ ├── http │ │ │ ├── FixedClockTest.java │ │ │ ├── MockHttpTransportTest.java │ │ │ ├── MockLowLevelHttpRequestTest.java │ │ │ └── javanet │ │ │ │ └── MockHttpUrlConnectionTest.java │ │ └── util │ │ │ └── MockBackOffTest.java │ │ └── util │ │ ├── ArrayMapTest.java │ │ ├── BackOffTest.java │ │ ├── BackOffUtilsTest.java │ │ ├── Base64Test.java │ │ ├── ClassInfoTest.java │ │ ├── ClockTest.java │ │ ├── DataMapTest.java │ │ ├── DataTest.java │ │ ├── DateTimeTest.java │ │ ├── ExponentialBackOffTest.java │ │ ├── FieldInfoTest.java │ │ ├── GenericDataTest.java │ │ ├── IOUtilsTest.java │ │ ├── LoggingStreamingContentTest.java │ │ ├── NanoClockTest.java │ │ ├── ObjectsTest.java │ │ ├── PemReaderTest.java │ │ ├── SecurityUtilsTest.java │ │ ├── StringUtilsTest.java │ │ ├── TypesTest.java │ │ └── escape │ │ ├── CharEscapersTest.java │ │ └── PercentEscaperTest.java │ └── resources │ ├── META-INF │ └── native-image │ │ └── com.google.http-client │ │ └── google-http-client │ │ ├── native-image.properties │ │ ├── reflect-config.json │ │ └── resource-config.json │ ├── com │ └── google │ │ └── api │ │ └── client │ │ └── util │ │ ├── cert.pem │ │ ├── mtlsCertAndKey.pem │ │ ├── privateKey.pem │ │ ├── secret.p12 │ │ └── secret.pem │ └── file.txt ├── instructions.html ├── pom.xml ├── renovate.json ├── samples ├── dailymotion-simple-cmdline-sample │ ├── instructions.html │ ├── logging.properties │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── google │ │ └── api │ │ └── services │ │ └── samples │ │ └── dailymotion │ │ └── cmdline │ │ └── simple │ │ └── DailyMotionSample.java ├── install-without-bom │ └── pom.xml ├── pom.xml ├── snapshot │ └── pom.xml └── snippets │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── json │ │ │ └── YouTubeSample.java │ └── resources │ │ └── youtube-search.json │ └── test │ └── java │ └── com │ └── example │ └── json │ └── YouTubeSampleTest.java └── versions.txt /.github/.release-please.yml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Code owners file. 2 | # This file controls who is tagged for review for any given pull request. 3 | 4 | # For syntax help see: 5 | # https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax 6 | 7 | * @googleapis/yoshi-java 8 | 9 | # The java-samples-reviewers team is the default owner for samples changes 10 | samples/**/*.java @googleapis/java-samples-reviewers 11 | 12 | # Generated snippets should not be owned by samples reviewers 13 | samples/snippets/generated/ @googleapis/yoshi-java 14 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Thanks for stopping by to let us know something could be better! 2 | 3 | Please be sure to include as much information as possible: 4 | 5 | #### Environment details 6 | 7 | - OS: 8 | - Java version: 9 | - google-http-java-client version: 10 | 11 | #### Steps to reproduce 12 | 13 | 1. ? 14 | 2. ? 15 | 16 | #### Stacktrace 17 | 18 | ``` 19 | Any relevant stacktrace here. 20 | ``` 21 | 22 | #### External references such as API reference guides used 23 | 24 | - ? 25 | 26 | #### Any additional information below 27 | 28 | Making sure to follow these steps will guarantee the quickest resolution possible. 29 | 30 | Thanks! 31 | 32 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | 5 | --- 6 | 7 | Thanks for stopping by to let us know something could be better! 8 | 9 | **PLEASE READ**: If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/) instead of filing on GitHub. This will ensure a timely response. 10 | 11 | Please run down the following list and make sure you've tried the usual "quick fixes": 12 | 13 | - Search the issues already opened: https://github.com/googleapis/google-http-java-client/issues 14 | - Check for answers on StackOverflow: http://stackoverflow.com/questions/tagged/google-cloud-platform 15 | 16 | If you are still having issues, please include as much information as possible: 17 | 18 | #### Environment details 19 | 20 | 1. Specify the API at the beginning of the title. For example, "BigQuery: ..."). 21 | General, Core, and Other are also allowed as types 22 | 2. OS type and version: 23 | 3. Java version: 24 | 4. version(s): 25 | 26 | #### Steps to reproduce 27 | 28 | 1. ? 29 | 2. ? 30 | 31 | #### Code example 32 | 33 | ```java 34 | // example 35 | ``` 36 | 37 | #### Stack trace 38 | ``` 39 | Any relevant stacktrace here. 40 | ``` 41 | 42 | #### External references such as API reference guides 43 | 44 | - ? 45 | 46 | #### Any additional information below 47 | 48 | 49 | Following these steps guarantees the quickest resolution possible. 50 | 51 | Thanks! 52 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this library 4 | 5 | --- 6 | 7 | Thanks for stopping by to let us know something could be better! 8 | 9 | **PLEASE READ**: If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/) instead of filing on GitHub. This will ensure a timely response. 10 | 11 | **Is your feature request related to a problem? Please describe.** 12 | What the problem is. Example: I'm always frustrated when [...] 13 | 14 | **Describe the solution you'd like** 15 | What you want to happen. 16 | 17 | **Describe alternatives you've considered** 18 | Any alternative solutions or features you've considered. 19 | 20 | **Additional context** 21 | Any other context or screenshots about the feature request. 22 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/support_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Support request 3 | about: If you have a support contract with Google, please create an issue in the Google Cloud Support console. 4 | 5 | --- 6 | 7 | **PLEASE READ**: If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/) instead of filing on GitHub. This will ensure a timely response. 8 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: 2 | - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/google-http-java-client/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea 3 | - [ ] Ensure the tests and linter pass 4 | - [ ] Code coverage does not decrease (if any source code was changed) 5 | - [ ] Appropriate docs were updated (if necessary) 6 | 7 | Fixes # ☕️ 8 | 9 | If you write sample code, please follow the [samples format]( 10 | https://github.com/GoogleCloudPlatform/java-docs-samples/blob/main/SAMPLE_FORMAT.md). 11 | -------------------------------------------------------------------------------- /.github/auto-label.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | requestsize: 15 | enabled: true 16 | -------------------------------------------------------------------------------- /.github/blunderbuss.yml: -------------------------------------------------------------------------------- 1 | # Configuration for the Blunderbuss GitHub app. For more info see 2 | # https://github.com/googleapis/repo-automation-bots/tree/main/packages/blunderbuss 3 | assign_prs_by: 4 | - labels: 5 | - samples 6 | to: 7 | - googleapis/java-samples-reviewers -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "maven" 4 | directory: "/" 5 | schedule: 6 | interval: "daily" 7 | # Disable version updates for Maven dependencies 8 | # we use renovate-bot as well as shared-dependencies BOM to update maven dependencies. 9 | ignore: 10 | - dependency-name: "*" 11 | - package-ecosystem: "pip" 12 | directory: "/" 13 | schedule: 14 | interval: "daily" 15 | # Disable version updates for pip dependencies 16 | # If a security vulnerability comes in, we will be notified about 17 | # it via template in the synthtool repository. 18 | ignore: 19 | - dependency-name: "*" 20 | -------------------------------------------------------------------------------- /.github/release-please.yml: -------------------------------------------------------------------------------- 1 | bumpMinorPreMajor: true 2 | handleGHRelease: true 3 | releaseType: java-yoshi 4 | branches: 5 | - bumpMinorPreMajor: true 6 | handleGHRelease: true 7 | releaseType: java-lts 8 | branch: 1.39.2-sp 9 | - bumpMinorPreMajor: true 10 | handleGHRelease: true 11 | releaseType: java-backport 12 | branch: 1.40.x 13 | - bumpMinorPreMajor: true 14 | handleGHRelease: true 15 | releaseType: java-backport 16 | branch: 1.41.x 17 | - bumpMinorPreMajor: true 18 | handleGHRelease: true 19 | releaseType: java-backport 20 | branch: 1.42.x 21 | - bumpMinorPreMajor: true 22 | handleGHRelease: true 23 | releaseType: java-backport 24 | branch: 1.43.x 25 | - bumpMinorPreMajor: true 26 | handleGHRelease: true 27 | releaseType: java-backport 28 | branch: 1.44.x 29 | - bumpMinorPreMajor: true 30 | handleGHRelease: true 31 | releaseType: java-backport 32 | branch: 1.46.x 33 | -------------------------------------------------------------------------------- /.github/release-trigger.yml: -------------------------------------------------------------------------------- 1 | enabled: true 2 | multiScmName: google-http-java-client 3 | -------------------------------------------------------------------------------- /.github/snippet-bot.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleapis/google-http-java-client/0d1726114ca678d8a9c8e3e231e0ab7205eb8395/.github/snippet-bot.yml -------------------------------------------------------------------------------- /.github/trusted-contribution.yml: -------------------------------------------------------------------------------- 1 | trustedContributors: 2 | - renovate-bot 3 | - gcf-owl-bot[bot] 4 | 5 | annotations: 6 | - type: comment 7 | text: "/gcbrun" 8 | - type: label 9 | text: "kokoro:force-run" 10 | -------------------------------------------------------------------------------- /.github/workflows/renovate_config_check.yaml: -------------------------------------------------------------------------------- 1 | name: Renovate Bot Config Validation 2 | 3 | on: 4 | pull_request: 5 | paths: 6 | - 'renovate.json' 7 | 8 | jobs: 9 | renovate_bot_config_validation: 10 | runs-on: ubuntu-24.04 11 | 12 | steps: 13 | - name: Checkout code 14 | uses: actions/checkout@v4 15 | 16 | - name: Set up Node.js 17 | uses: actions/setup-node@v4 18 | with: 19 | node-version: '20' 20 | 21 | - name: Install Renovate and Config Validator 22 | run: | 23 | npm install -g npm@latest 24 | npm install --global renovate 25 | renovate-config-validator 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gitignore 2 | 3 | # Packages 4 | dist 5 | bin 6 | var 7 | sdist 8 | target 9 | 10 | # Unit test / coverage reports 11 | .coverage 12 | .tox 13 | nosetests.xml 14 | 15 | # Translations 16 | *.mo 17 | 18 | # Mr Developer 19 | .mr.developer.cfg 20 | 21 | **/.project 22 | .pydevproject 23 | *.iml 24 | .idea 25 | .settings 26 | .DS_Store 27 | **/.classpath 28 | **/.checkstyle 29 | 30 | # Python utilities 31 | *.pyc 32 | -------------------------------------------------------------------------------- /.kokoro/build.bat: -------------------------------------------------------------------------------- 1 | :: Copyright 2022 Google LLC 2 | :: 3 | :: Licensed under the Apache License, Version 2.0 (the "License"); 4 | :: you may not use this file except in compliance with the License. 5 | :: You may obtain a copy of the License at 6 | :: 7 | :: http://www.apache.org/licenses/LICENSE-2.0 8 | :: 9 | :: Unless required by applicable law or agreed to in writing, software 10 | :: distributed under the License is distributed on an "AS IS" BASIS, 11 | :: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | :: See the License for the specific language governing permissions and 13 | :: limitations under the License. 14 | :: Github action job to test core java library features on 15 | :: downstream client libraries before they are released. 16 | :: See documentation in type-shell-output.bat 17 | 18 | "C:\Program Files\Git\bin\bash.exe" %~dp0build.sh 19 | -------------------------------------------------------------------------------- /.kokoro/coerce_logs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2019 Google LLC 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # This script finds and moves sponge logs so that they can be found by placer 17 | # and are not flagged as flaky by sponge. 18 | 19 | set -eo pipefail 20 | 21 | ## Get the directory of the build script 22 | scriptDir=$(realpath $(dirname "${BASH_SOURCE[0]}")) 23 | ## cd to the parent directory, i.e. the root of the git repo 24 | cd ${scriptDir}/.. 25 | 26 | job=$(basename ${KOKORO_JOB_NAME}) 27 | 28 | echo "coercing sponge logs..." 29 | for xml in `find . -name *-sponge_log.xml` 30 | do 31 | class=$(basename ${xml} | cut -d- -f2) 32 | dir=$(dirname ${xml})/${job}/${class} 33 | text=$(dirname ${xml})/${class}-sponge_log.txt 34 | mkdir -p ${dir} 35 | mv ${xml} ${dir}/sponge_log.xml 36 | mv ${text} ${dir}/sponge_log.txt 37 | done 38 | -------------------------------------------------------------------------------- /.kokoro/common.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Download trampoline resources. These will be in ${KOKORO_GFILE_DIR} 4 | gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" 5 | 6 | # All builds use the trampoline script to run in docker. 7 | build_file: "google-http-java-client/.kokoro/trampoline.sh" 8 | 9 | # Tell the trampoline which build file to use. 10 | env_vars: { 11 | key: "TRAMPOLINE_BUILD_FILE" 12 | value: "github/google-http-java-client/.kokoro/build.sh" 13 | } 14 | -------------------------------------------------------------------------------- /.kokoro/common.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2020 Google LLC 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | function retry_with_backoff { 17 | attempts_left=$1 18 | sleep_seconds=$2 19 | shift 2 20 | command=$@ 21 | 22 | 23 | # store current flag state 24 | flags=$- 25 | 26 | # allow a failures to continue 27 | set +e 28 | ${command} 29 | exit_code=$? 30 | 31 | # restore "e" flag 32 | if [[ ${flags} =~ e ]] 33 | then set -e 34 | else set +e 35 | fi 36 | 37 | if [[ $exit_code == 0 ]] 38 | then 39 | return 0 40 | fi 41 | 42 | # failure 43 | if [[ ${attempts_left} > 0 ]] 44 | then 45 | echo "failure (${exit_code}), sleeping ${sleep_seconds}..." 46 | sleep ${sleep_seconds} 47 | new_attempts=$((${attempts_left} - 1)) 48 | new_sleep=$((${sleep_seconds} * 2)) 49 | retry_with_backoff ${new_attempts} ${new_sleep} ${command} 50 | fi 51 | 52 | return $exit_code 53 | } 54 | 55 | ## Helper functionss 56 | function now() { date +"%Y-%m-%d %H:%M:%S" | tr -d '\n'; } 57 | function msg() { println "$*" >&2; } 58 | function println() { printf '%s\n' "$(now) $*"; } 59 | 60 | ## Helper comment to trigger updated repo dependency release -------------------------------------------------------------------------------- /.kokoro/continuous/common.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Build logs will be here 4 | action { 5 | define_artifacts { 6 | regex: "**/*sponge_log.xml" 7 | regex: "**/*sponge_log.txt" 8 | } 9 | } 10 | 11 | # Download trampoline resources. 12 | gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" 13 | 14 | # Use the trampoline script to run in docker. 15 | build_file: "google-http-java-client/.kokoro/trampoline.sh" 16 | 17 | env_vars: { 18 | key: "TRAMPOLINE_BUILD_FILE" 19 | value: "github/google-http-java-client/.kokoro/build.sh" 20 | } 21 | 22 | env_vars: { 23 | key: "JOB_TYPE" 24 | value: "test" 25 | } 26 | -------------------------------------------------------------------------------- /.kokoro/continuous/java10.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | env_vars: { 5 | key: "TRAMPOLINE_IMAGE" 6 | value: "gcr.io/cloud-devrel-kokoro-resources/java10" 7 | } 8 | -------------------------------------------------------------------------------- /.kokoro/continuous/java8.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | env_vars: { 5 | key: "TRAMPOLINE_IMAGE" 6 | value: "gcr.io/cloud-devrel-kokoro-resources/java8" 7 | } 8 | 9 | env_vars: { 10 | key: "REPORT_COVERAGE" 11 | value: "true" 12 | } 13 | -------------------------------------------------------------------------------- /.kokoro/continuous/propose_release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2019 Google LLC 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -eo pipefail 18 | 19 | export NPM_CONFIG_PREFIX=/home/node/.npm-global 20 | 21 | if [ -f ${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-url-release-please ]; then 22 | # Groom the release PR as new commits are merged. 23 | npx release-please release-pr --token=${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-token-release-please \ 24 | --repo-url=googleapis/google-http-java-client \ 25 | --package-name="google-http-client" \ 26 | --api-url=${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-url-release-please \ 27 | --proxy-key=${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-key-release-please \ 28 | --release-type=java-yoshi 29 | fi 30 | -------------------------------------------------------------------------------- /.kokoro/dependencies.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2019 Google LLC 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | set -eo pipefail 17 | shopt -s nullglob 18 | 19 | ## Get the directory of the build script 20 | scriptDir=$(realpath $(dirname "${BASH_SOURCE[0]}")) 21 | ## cd to the parent directory, i.e. the root of the git repo 22 | cd ${scriptDir}/.. 23 | 24 | # include common functions 25 | source ${scriptDir}/common.sh 26 | 27 | # Print out Java 28 | java -version 29 | echo $JOB_TYPE 30 | 31 | function determineMavenOpts() { 32 | local javaVersion=$( 33 | # filter down to the version line, then pull out the version between quotes, 34 | # then trim the version number down to its minimal number (removing any 35 | # update or suffix number). 36 | java -version 2>&1 | grep "version" \ 37 | | sed -E 's/^.*"(.*?)".*$/\1/g' \ 38 | | sed -E 's/^(1\.[0-9]\.0).*$/\1/g' 39 | ) 40 | 41 | # Extract the major version for simple comparison 42 | local javaMajorVersion=$(echo $javaVersion | cut -d'.' -f1) 43 | 44 | if [[ $javaMajorVersion -ge 17 ]] 45 | then 46 | # MaxPermSize is no longer supported as of jdk 17 47 | echo -n "-Xmx1024m" 48 | else 49 | echo -n "-Xmx1024m -XX:MaxPermSize=128m" 50 | fi 51 | } 52 | 53 | export MAVEN_OPTS=$(determineMavenOpts) 54 | 55 | # this should run maven enforcer 56 | retry_with_backoff 3 10 \ 57 | mvn install -B -V -ntp \ 58 | -DskipTests=true \ 59 | -Dmaven.javadoc.skip=true \ 60 | -Dclirr.skip=true 61 | 62 | mvn -B dependency:analyze -DfailOnWarning=true 63 | -------------------------------------------------------------------------------- /.kokoro/nightly/common.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Build logs will be here 4 | action { 5 | define_artifacts { 6 | regex: "**/*sponge_log.xml" 7 | regex: "**/*sponge_log.txt" 8 | } 9 | } 10 | 11 | # Download trampoline resources. 12 | gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" 13 | 14 | # Use the trampoline script to run in docker. 15 | build_file: "google-http-java-client/.kokoro/trampoline.sh" 16 | 17 | env_vars: { 18 | key: "TRAMPOLINE_BUILD_FILE" 19 | value: "github/google-http-java-client/.kokoro/build.sh" 20 | } 21 | 22 | env_vars: { 23 | key: "JOB_TYPE" 24 | value: "test" 25 | } 26 | -------------------------------------------------------------------------------- /.kokoro/nightly/integration.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | env_vars: { 5 | key: "TRAMPOLINE_IMAGE" 6 | value: "gcr.io/cloud-devrel-kokoro-resources/java8" 7 | } 8 | 9 | env_vars: { 10 | key: "JOB_TYPE" 11 | value: "integration" 12 | } 13 | # TODO: remove this after we've migrated all tests and scripts 14 | env_vars: { 15 | key: "GCLOUD_PROJECT" 16 | value: "java-docs-samples-testing" 17 | } 18 | 19 | env_vars: { 20 | key: "GOOGLE_CLOUD_PROJECT" 21 | value: "java-docs-samples-testing" 22 | } 23 | 24 | env_vars: { 25 | key: "ENABLE_FLAKYBOT" 26 | value: "true" 27 | } 28 | 29 | env_vars: { 30 | key: "GOOGLE_APPLICATION_CREDENTIALS" 31 | value: "secret_manager/java-it-service-account" 32 | } 33 | 34 | env_vars: { 35 | key: "SECRET_MANAGER_KEYS" 36 | value: "java-it-service-account" 37 | } 38 | 39 | -------------------------------------------------------------------------------- /.kokoro/nightly/java11-integration.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | env_vars: { 5 | key: "TRAMPOLINE_IMAGE" 6 | value: "gcr.io/cloud-devrel-public-resources/java11014" 7 | } 8 | 9 | env_vars: { 10 | key: "JOB_TYPE" 11 | value: "integration" 12 | } 13 | # TODO: remove this after we've migrated all tests and scripts 14 | env_vars: { 15 | key: "GCLOUD_PROJECT" 16 | value: "gcloud-devel" 17 | } 18 | 19 | env_vars: { 20 | key: "GOOGLE_CLOUD_PROJECT" 21 | value: "gcloud-devel" 22 | } 23 | 24 | env_vars: { 25 | key: "ENABLE_FLAKYBOT" 26 | value: "true" 27 | } 28 | 29 | env_vars: { 30 | key: "GOOGLE_APPLICATION_CREDENTIALS" 31 | value: "secret_manager/java-it-service-account" 32 | } 33 | 34 | env_vars: { 35 | key: "SECRET_MANAGER_KEYS" 36 | value: "java-it-service-account" 37 | } 38 | 39 | -------------------------------------------------------------------------------- /.kokoro/nightly/java11.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | env_vars: { 5 | key: "TRAMPOLINE_IMAGE" 6 | value: "gcr.io/cloud-devrel-kokoro-resources/java11" 7 | } 8 | -------------------------------------------------------------------------------- /.kokoro/nightly/java7.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | env_vars: { 5 | key: "TRAMPOLINE_IMAGE" 6 | value: "gcr.io/cloud-devrel-kokoro-resources/java7" 7 | } 8 | -------------------------------------------------------------------------------- /.kokoro/nightly/java8-osx.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | build_file: "google-http-java-client/.kokoro/build.sh" 4 | -------------------------------------------------------------------------------- /.kokoro/nightly/java8-win.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | build_file: "google-http-java-client/.kokoro/build.bat" 4 | -------------------------------------------------------------------------------- /.kokoro/nightly/java8.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | env_vars: { 5 | key: "TRAMPOLINE_IMAGE" 6 | value: "gcr.io/cloud-devrel-kokoro-resources/java8" 7 | } 8 | 9 | env_vars: { 10 | key: "REPORT_COVERAGE" 11 | value: "true" 12 | } 13 | -------------------------------------------------------------------------------- /.kokoro/nightly/samples.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | env_vars: { 5 | key: "TRAMPOLINE_IMAGE" 6 | value: "gcr.io/cloud-devrel-kokoro-resources/java8" 7 | } 8 | 9 | env_vars: { 10 | key: "JOB_TYPE" 11 | value: "samples" 12 | } 13 | 14 | # TODO: remove this after we've migrated all tests and scripts 15 | env_vars: { 16 | key: "GCLOUD_PROJECT" 17 | value: "java-docs-samples-testing" 18 | } 19 | 20 | env_vars: { 21 | key: "GOOGLE_CLOUD_PROJECT" 22 | value: "java-docs-samples-testing" 23 | } 24 | 25 | env_vars: { 26 | key: "GOOGLE_APPLICATION_CREDENTIALS" 27 | value: "secret_manager/java-docs-samples-service-account" 28 | } 29 | 30 | env_vars: { 31 | key: "SECRET_MANAGER_KEYS" 32 | value: "java-docs-samples-service-account" 33 | } 34 | 35 | env_vars: { 36 | key: "ENABLE_FLAKYBOT" 37 | value: "true" 38 | } 39 | -------------------------------------------------------------------------------- /.kokoro/populate-secrets.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2020 Google LLC. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | set -eo pipefail 17 | 18 | function now { date +"%Y-%m-%d %H:%M:%S" | tr -d '\n' ;} 19 | function msg { println "$*" >&2 ;} 20 | function println { printf '%s\n' "$(now) $*" ;} 21 | 22 | 23 | # Populates requested secrets set in SECRET_MANAGER_KEYS from service account: 24 | # kokoro-trampoline@cloud-devrel-kokoro-resources.iam.gserviceaccount.com 25 | SECRET_LOCATION="${KOKORO_GFILE_DIR}/secret_manager" 26 | msg "Creating folder on disk for secrets: ${SECRET_LOCATION}" 27 | mkdir -p ${SECRET_LOCATION} 28 | for key in $(echo ${SECRET_MANAGER_KEYS} | sed "s/,/ /g") 29 | do 30 | msg "Retrieving secret ${key}" 31 | docker run --entrypoint=gcloud \ 32 | --volume=${KOKORO_GFILE_DIR}:${KOKORO_GFILE_DIR} \ 33 | gcr.io/google.com/cloudsdktool/cloud-sdk \ 34 | secrets versions access latest \ 35 | --project cloud-devrel-kokoro-resources \ 36 | --secret ${key} > \ 37 | "${SECRET_LOCATION}/${key}" 38 | if [[ $? == 0 ]]; then 39 | msg "Secret written to ${SECRET_LOCATION}/${key}" 40 | else 41 | msg "Error retrieving secret ${key}" 42 | fi 43 | done 44 | -------------------------------------------------------------------------------- /.kokoro/presubmit/clirr.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | 5 | env_vars: { 6 | key: "TRAMPOLINE_IMAGE" 7 | value: "gcr.io/cloud-devrel-kokoro-resources/java8" 8 | } 9 | 10 | env_vars: { 11 | key: "JOB_TYPE" 12 | value: "clirr" 13 | } -------------------------------------------------------------------------------- /.kokoro/presubmit/common.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Build logs will be here 4 | action { 5 | define_artifacts { 6 | regex: "**/*sponge_log.xml" 7 | regex: "**/*sponge_log.txt" 8 | } 9 | } 10 | 11 | # Download trampoline resources. 12 | gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" 13 | 14 | # Use the trampoline script to run in docker. 15 | build_file: "google-http-java-client/.kokoro/trampoline.sh" 16 | 17 | env_vars: { 18 | key: "TRAMPOLINE_BUILD_FILE" 19 | value: "github/google-http-java-client/.kokoro/build.sh" 20 | } 21 | 22 | env_vars: { 23 | key: "JOB_TYPE" 24 | value: "test" 25 | } 26 | -------------------------------------------------------------------------------- /.kokoro/presubmit/dependencies.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | env_vars: { 5 | key: "TRAMPOLINE_IMAGE" 6 | value: "gcr.io/cloud-devrel-kokoro-resources/java8" 7 | } 8 | 9 | env_vars: { 10 | key: "TRAMPOLINE_BUILD_FILE" 11 | value: "github/google-http-java-client/.kokoro/dependencies.sh" 12 | } 13 | -------------------------------------------------------------------------------- /.kokoro/presubmit/graalvm-native-a.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | build_file: "google-http-java-client/.kokoro/build.sh" 4 | 5 | env_vars: { 6 | key: "JOB_TYPE" 7 | value: "graalvm" 8 | } 9 | 10 | # TODO: remove this after we've migrated all tests and scripts 11 | env_vars: { 12 | key: "GCLOUD_PROJECT" 13 | value: "gcloud-devel" 14 | } 15 | 16 | env_vars: { 17 | key: "GOOGLE_CLOUD_PROJECT" 18 | value: "gcloud-devel" 19 | } 20 | 21 | env_vars: { 22 | key: "GOOGLE_APPLICATION_CREDENTIALS" 23 | value: "secret_manager/java-it-service-account" 24 | } 25 | 26 | env_vars: { 27 | key: "SECRET_MANAGER_KEYS" 28 | value: "java-it-service-account" 29 | } 30 | 31 | container_properties { 32 | docker_image: "us-docker.pkg.dev/java-graalvm-ci-prod/graalvm-integration-testing/graalvm_a:1.16.0" 33 | } 34 | -------------------------------------------------------------------------------- /.kokoro/presubmit/graalvm-native-b.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | build_file: "google-http-java-client/.kokoro/build.sh" 4 | 5 | env_vars: { 6 | key: "JOB_TYPE" 7 | value: "graalvm" 8 | } 9 | 10 | # TODO: remove this after we've migrated all tests and scripts 11 | env_vars: { 12 | key: "GCLOUD_PROJECT" 13 | value: "gcloud-devel" 14 | } 15 | 16 | env_vars: { 17 | key: "GOOGLE_CLOUD_PROJECT" 18 | value: "gcloud-devel" 19 | } 20 | 21 | env_vars: { 22 | key: "GOOGLE_APPLICATION_CREDENTIALS" 23 | value: "secret_manager/java-it-service-account" 24 | } 25 | 26 | env_vars: { 27 | key: "SECRET_MANAGER_KEYS" 28 | value: "java-it-service-account" 29 | } 30 | 31 | container_properties { 32 | docker_image: "us-docker.pkg.dev/java-graalvm-ci-prod/graalvm-integration-testing/graalvm_b:1.16.0" 33 | } 34 | -------------------------------------------------------------------------------- /.kokoro/presubmit/graalvm-native-c.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | build_file: "google-http-java-client/.kokoro/build.sh" 4 | 5 | env_vars: { 6 | key: "JOB_TYPE" 7 | value: "graalvm" 8 | } 9 | 10 | # TODO: remove this after we've migrated all tests and scripts 11 | env_vars: { 12 | key: "GCLOUD_PROJECT" 13 | value: "gcloud-devel" 14 | } 15 | 16 | env_vars: { 17 | key: "GOOGLE_CLOUD_PROJECT" 18 | value: "gcloud-devel" 19 | } 20 | 21 | env_vars: { 22 | key: "GOOGLE_APPLICATION_CREDENTIALS" 23 | value: "secret_manager/java-it-service-account" 24 | } 25 | 26 | env_vars: { 27 | key: "SECRET_MANAGER_KEYS" 28 | value: "java-it-service-account" 29 | } 30 | 31 | container_properties { 32 | docker_image: "us-docker.pkg.dev/java-graalvm-ci-prod/graalvm-integration-testing/graalvm_c:1.16.0" 33 | } 34 | -------------------------------------------------------------------------------- /.kokoro/presubmit/integration.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | env_vars: { 5 | key: "TRAMPOLINE_IMAGE" 6 | value: "gcr.io/cloud-devrel-kokoro-resources/java8" 7 | } 8 | 9 | env_vars: { 10 | key: "JOB_TYPE" 11 | value: "integration" 12 | } 13 | 14 | # TODO: remove this after we've migrated all tests and scripts 15 | env_vars: { 16 | key: "GCLOUD_PROJECT" 17 | value: "gcloud-devel" 18 | } 19 | 20 | env_vars: { 21 | key: "GOOGLE_CLOUD_PROJECT" 22 | value: "gcloud-devel" 23 | } 24 | 25 | env_vars: { 26 | key: "GOOGLE_APPLICATION_CREDENTIALS" 27 | value: "secret_manager/java-it-service-account" 28 | } 29 | 30 | env_vars: { 31 | key: "SECRET_MANAGER_KEYS" 32 | value: "java-it-service-account" 33 | } 34 | 35 | -------------------------------------------------------------------------------- /.kokoro/presubmit/java10.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | env_vars: { 5 | key: "TRAMPOLINE_IMAGE" 6 | value: "gcr.io/cloud-devrel-kokoro-resources/java10" 7 | } 8 | -------------------------------------------------------------------------------- /.kokoro/presubmit/java11.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | env_vars: { 5 | key: "TRAMPOLINE_IMAGE" 6 | value: "gcr.io/cloud-devrel-kokoro-resources/java11" 7 | } 8 | -------------------------------------------------------------------------------- /.kokoro/presubmit/java7.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | env_vars: { 5 | key: "TRAMPOLINE_IMAGE" 6 | value: "gcr.io/cloud-devrel-kokoro-resources/java7" 7 | } 8 | -------------------------------------------------------------------------------- /.kokoro/presubmit/java8-osx.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | build_file: "google-http-java-client/.kokoro/build.sh" 4 | -------------------------------------------------------------------------------- /.kokoro/presubmit/java8-win.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | build_file: "google-http-java-client/.kokoro/build.bat" 4 | -------------------------------------------------------------------------------- /.kokoro/presubmit/java8.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | env_vars: { 5 | key: "TRAMPOLINE_IMAGE" 6 | value: "gcr.io/cloud-devrel-kokoro-resources/java8" 7 | } 8 | 9 | env_vars: { 10 | key: "REPORT_COVERAGE" 11 | value: "true" 12 | } 13 | -------------------------------------------------------------------------------- /.kokoro/presubmit/linkage-monitor.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | env_vars: { 5 | key: "TRAMPOLINE_IMAGE" 6 | value: "gcr.io/cloud-devrel-kokoro-resources/java8" 7 | } 8 | 9 | env_vars: { 10 | key: "TRAMPOLINE_BUILD_FILE" 11 | value: "github/google-http-java-client/.kokoro/linkage-monitor.sh" 12 | } -------------------------------------------------------------------------------- /.kokoro/presubmit/lint.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | 5 | env_vars: { 6 | key: "TRAMPOLINE_IMAGE" 7 | value: "gcr.io/cloud-devrel-kokoro-resources/java8" 8 | } 9 | 10 | env_vars: { 11 | key: "JOB_TYPE" 12 | value: "lint" 13 | } -------------------------------------------------------------------------------- /.kokoro/presubmit/samples.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Configure the docker image for kokoro-trampoline. 4 | env_vars: { 5 | key: "TRAMPOLINE_IMAGE" 6 | value: "gcr.io/cloud-devrel-kokoro-resources/java8" 7 | } 8 | 9 | env_vars: { 10 | key: "JOB_TYPE" 11 | value: "samples" 12 | } 13 | 14 | # TODO: remove this after we've migrated all tests and scripts 15 | env_vars: { 16 | key: "GCLOUD_PROJECT" 17 | value: "java-docs-samples-testing" 18 | } 19 | 20 | env_vars: { 21 | key: "GOOGLE_CLOUD_PROJECT" 22 | value: "java-docs-samples-testing" 23 | } 24 | 25 | env_vars: { 26 | key: "GOOGLE_APPLICATION_CREDENTIALS" 27 | value: "secret_manager/java-docs-samples-service-account" 28 | } 29 | 30 | env_vars: { 31 | key: "SECRET_MANAGER_KEYS" 32 | value: "java-docs-samples-service-account" 33 | } -------------------------------------------------------------------------------- /.kokoro/readme.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2020 Google LLC 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | set -eo pipefail 17 | 18 | cd ${KOKORO_ARTIFACTS_DIR}/github/google-http-java-client 19 | 20 | # Disable buffering, so that the logs stream through. 21 | export PYTHONUNBUFFERED=1 22 | 23 | # Kokoro exposes this as a file, but the scripts expect just a plain variable. 24 | export GITHUB_TOKEN=$(cat ${KOKORO_KEYSTORE_DIR}/73713_yoshi-automation-github-key) 25 | 26 | # Setup git credentials 27 | echo "https://${GITHUB_TOKEN}:@github.com" >> ~/.git-credentials 28 | git config --global credential.helper 'store --file ~/.git-credentials' 29 | 30 | python3.6 -m pip install git+https://github.com/googleapis/synthtool.git#egg=gcp-synthtool 31 | 32 | set +e 33 | python3.6 -m autosynth.synth \ 34 | --repository=googleapis/google-http-java-client \ 35 | --synth-file-name=.github/readme/synth.py \ 36 | --metadata-path=.github/readme/synth.metadata \ 37 | --pr-title="chore: regenerate README" \ 38 | --branch-suffix="readme" 39 | 40 | # autosynth returns 28 to signal there are no changes 41 | RETURN_CODE=$? 42 | if [[ ${RETURN_CODE} -ne 0 && ${RETURN_CODE} -ne 28 ]] 43 | then 44 | exit ${RETURN_CODE} 45 | fi 46 | -------------------------------------------------------------------------------- /.kokoro/trampoline.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2018 Google LLC 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | set -eo pipefail 16 | # Always run the cleanup script, regardless of the success of bouncing into 17 | # the container. 18 | function cleanup() { 19 | chmod +x ${KOKORO_GFILE_DIR}/trampoline_cleanup.sh 20 | ${KOKORO_GFILE_DIR}/trampoline_cleanup.sh 21 | echo "cleanup"; 22 | } 23 | trap cleanup EXIT 24 | 25 | $(dirname $0)/populate-secrets.sh # Secret Manager secrets. 26 | python3 "${KOKORO_GFILE_DIR}/trampoline_v1.py" 27 | -------------------------------------------------------------------------------- /.repo-metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "api_shortname": "google-http-client", 3 | "name_pretty": "Google HTTP Java Client", 4 | "client_documentation": "https://cloud.google.com/java/docs/reference/google-http-client/latest/history", 5 | "release_level": "stable", 6 | "language": "java", 7 | "repo": "googleapis/google-http-java-client", 8 | "repo_short": "google-http-java-client", 9 | "library_type": "CORE", 10 | "distribution_name": "com.google.http-client:google-http-client" 11 | } 12 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | To report a security issue, please use [g.co/vulnz](https://g.co/vulnz). 4 | 5 | The Google Security Team will respond within 5 working days of your report on g.co/vulnz. 6 | 7 | We use g.co/vulnz for our intake, and do coordination and disclosure here using GitHub Security Advisory to privately discuss and fix the issue. 8 | -------------------------------------------------------------------------------- /checkstyle-suppressions.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /docs/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-dinky 2 | title: Google HTTP Client for Java 3 | -------------------------------------------------------------------------------- /docs/_data/navigation.yml: -------------------------------------------------------------------------------- 1 | toc: 2 | - page: Overview 3 | url: index.html 4 | - page: Setup Instructions 5 | url: setup.html 6 | - page: Component Modules 7 | url: component-modules.html 8 | - page: Android 9 | url: android.html 10 | - page: Google App Engine 11 | url: google-app-engine.html 12 | - page: HTTP Transport 13 | url: http-transport.html 14 | - page: JSON 15 | url: json.html 16 | - page: Exponential Backoff 17 | url: exponential-backoff.html 18 | - page: Unit Testing 19 | url: unit-testing.html 20 | - page: Support 21 | url: support.html -------------------------------------------------------------------------------- /docs/support.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Support 3 | --- 4 | 5 | # Support 6 | 7 | ## The Google HTTP Client Library for Java Community 8 | 9 | ### Ask development questions 10 | 11 | Ask questions on StackOverflow: 12 | 13 | * Use the [google-api][so-google-api] tag, and optionally [java][so-java] or [android][so-android] 14 | or [java google-app-engine][so-java-gae]. 15 | * You can also use the [google-http-java-client][so-http-client] tag. 16 | * For tips on asking StackOverflow questions, see [How to Ask][so-how-to-ask]. 17 | 18 | **Note:** Please do not email the project contributors directly. 19 | 20 | ### File feature requests and defects 21 | 22 | You can suggest features and report issues on our public [Issue Tracker][issues]. This is a great 23 | place for the community to discuss and track implementations of features or resolution of bug fixes, 24 | as well as share workarounds and patches. 25 | 26 | If you find a bug: 27 | 28 | * View [known bugs][issues], and if a known bug corresponds to the issue you are seeing, "star" it 29 | or comment on it. 30 | * If the issue you are seeing has not yet been reported, [file a bug report][new-issue]. 31 | 32 | ### Contribute 33 | 34 | This is an [open-source][http-client] library, and [contributions][contributions] are welcome. 35 | 36 | [so-google-api]: http://stackoverflow.com/questions/tagged/google-api 37 | [so-java]: http://stackoverflow.com/questions/tagged/google-api+java 38 | [so-android]: http://stackoverflow.com/questions/tagged/google-api+android 39 | [so-java-gae]: http://stackoverflow.com/questions/tagged/google-api+java+google-app-engine 40 | [so-http-client]: http://stackoverflow.com/questions/tagged/google-http-java-client 41 | [so-how-to-ask]: http://stackoverflow.com/questions/ask 42 | [issues]: https://github.com/googleapis/google-http-java-client/issues 43 | [new-issue]: https://github.com/google/google-http-java-client/issues/new 44 | [http-client]: https://github.com/googleapis/google-http-java-client 45 | [contributions]: https://github.com/googleapis/google-http-java-client/blob/master/CONTRIBUTING.md 46 | -------------------------------------------------------------------------------- /google-http-client-android-test/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /google-http-client-android-test/src/main/java/com/google/api/client/extensions/android/json/FakeTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | package com.google.api.client.extensions.android.json; 15 | 16 | import junit.framework.TestCase; 17 | 18 | /** 19 | * Fake test case to force Maven test runner to run the tests on device. 20 | * 21 | * @author Yaniv Inbar 22 | */ 23 | public class FakeTest extends TestCase { 24 | 25 | public FakeTest(String name) { 26 | super(name); 27 | } 28 | 29 | public final void test() throws Exception {} 30 | } 31 | -------------------------------------------------------------------------------- /google-http-client-android-test/src/main/java/com/google/api/client/extensions/android/json/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * Android test project for {@code google-http-client-android}. 17 | * 18 | * @author Yaniv Inbar 19 | */ 20 | package com.google.api.client.extensions.android.json; 21 | -------------------------------------------------------------------------------- /google-http-client-android/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /google-http-client-android/project.properties: -------------------------------------------------------------------------------- 1 | target=android-18 2 | -------------------------------------------------------------------------------- /google-http-client-android/src/main/java/com/google/api/client/extensions/android/AndroidUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.extensions.android; 16 | 17 | import android.os.Build; 18 | import com.google.api.client.util.Beta; 19 | import com.google.api.client.util.Preconditions; 20 | 21 | /** 22 | * {@link Beta}
23 | * Utilities for Android. 24 | * 25 | * @since 1.11 26 | * @author Yaniv Inbar 27 | */ 28 | @Beta 29 | public class AndroidUtils { 30 | 31 | /** 32 | * Returns whether the SDK version is the given level or higher. 33 | * 34 | * @see android.os.Build.VERSION_CODES 35 | */ 36 | public static boolean isMinimumSdkLevel(int minimumSdkLevel) { 37 | return Build.VERSION.SDK_INT >= minimumSdkLevel; 38 | } 39 | 40 | /** 41 | * Throws an {@link IllegalArgumentException} if {@link #isMinimumSdkLevel(int)} is {@code false} 42 | * on the given level. 43 | * 44 | * @see android.os.Build.VERSION_CODES 45 | */ 46 | public static void checkMinimumSdkLevel(int minimumSdkLevel) { 47 | Preconditions.checkArgument( 48 | isMinimumSdkLevel(minimumSdkLevel), 49 | "running on Android SDK level %s but requires minimum %s", 50 | Build.VERSION.SDK_INT, 51 | minimumSdkLevel); 52 | } 53 | 54 | private AndroidUtils() {} 55 | } 56 | -------------------------------------------------------------------------------- /google-http-client-android/src/main/java/com/google/api/client/extensions/android/http/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * {@link com.google.api.client.util.Beta}
17 | * Utilities for Android HTTP transport. 18 | * 19 | * @since 1.11 20 | * @author Yaniv Inbar 21 | */ 22 | @com.google.api.client.util.Beta 23 | package com.google.api.client.extensions.android.http; 24 | -------------------------------------------------------------------------------- /google-http-client-android/src/main/java/com/google/api/client/extensions/android/json/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * {@link com.google.api.client.util.Beta}
17 | * Low-level implementation of the GSON parser library built-in to the Android 3.0 SDK. 18 | * 19 | * @since 1.11 20 | * @author Yaniv Inbar 21 | */ 22 | @com.google.api.client.util.Beta 23 | package com.google.api.client.extensions.android.json; 24 | -------------------------------------------------------------------------------- /google-http-client-android/src/main/java/com/google/api/client/extensions/android/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * {@link com.google.api.client.util.Beta}
17 | * Utilities for Android. 18 | * 19 | * @since 1.11 20 | * @author Yaniv Inbar 21 | */ 22 | @com.google.api.client.util.Beta 23 | package com.google.api.client.extensions.android; 24 | -------------------------------------------------------------------------------- /google-http-client-apache-v2/src/main/java/com/google/api/client/http/apache/v2/HttpExtensionMethod.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.http.apache.v2; 16 | 17 | import com.google.api.client.util.Preconditions; 18 | import java.net.URI; 19 | import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; 20 | 21 | /** 22 | * HTTP extension method. 23 | * 24 | * @author Yaniv Inbar 25 | */ 26 | final class HttpExtensionMethod extends HttpEntityEnclosingRequestBase { 27 | 28 | /** Request method name. */ 29 | private final String methodName; 30 | 31 | /** 32 | * @param methodName request method name 33 | * @param uri URI 34 | */ 35 | public HttpExtensionMethod(String methodName, String uri) { 36 | this.methodName = Preconditions.checkNotNull(methodName); 37 | setURI(URI.create(uri)); 38 | } 39 | 40 | @Override 41 | public String getMethod() { 42 | return methodName; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /google-http-client-apache-v2/src/main/java/com/google/api/client/http/apache/v2/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * HTTP Transport library for Google API's based on Apache HTTP Client version 4.5+. 17 | * 18 | * @since 1.30 19 | * @author Yaniv Inbar 20 | */ 21 | package com.google.api.client.http.apache.v2; 22 | -------------------------------------------------------------------------------- /google-http-client-apache-v2/src/main/resources/META-INF/native-image/com.google.http-client/google-http-client-apache-v2/reflect-config.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "org.apache.commons.logging.impl.LogFactoryImpl", 4 | "queryAllDeclaredConstructors": true, 5 | "queryAllPublicConstructors": true, 6 | "queryAllDeclaredMethods": true, 7 | "allPublicMethods": true, 8 | "allDeclaredFields": true, 9 | "methods": [ 10 | { 11 | "name": "", 12 | "parameterTypes": [] 13 | } 14 | ] 15 | }, 16 | { 17 | "name": "org.apache.commons.logging.impl.Log4JLogger", 18 | "queryAllDeclaredConstructors": true, 19 | "queryAllPublicConstructors": true, 20 | "queryAllDeclaredMethods": true, 21 | "allPublicMethods": true, 22 | "allDeclaredFields": true 23 | }, 24 | { 25 | "name": "org.apache.commons.logging.impl.Jdk14Logger", 26 | "queryAllDeclaredConstructors": true, 27 | "queryAllPublicConstructors": true, 28 | "queryAllDeclaredMethods": true, 29 | "allPublicMethods": true, 30 | "allDeclaredFields": true 31 | }, 32 | { 33 | "name": "org.apache.commons.logging.impl.SimpleLog", 34 | "queryAllDeclaredConstructors": true, 35 | "queryAllPublicConstructors": true, 36 | "queryAllDeclaredMethods": true, 37 | "allDeclaredConstructors": true, 38 | "allPublicConstructors": true, 39 | "allPublicMethods": true, 40 | "allDeclaredFields": true 41 | }, 42 | { 43 | "name": "org.apache.commons.logging.impl.Jdk13LumberjackLogger", 44 | "queryAllDeclaredConstructors": true, 45 | "queryAllPublicConstructors": true, 46 | "queryAllDeclaredMethods": true, 47 | "allPublicMethods": true, 48 | "allDeclaredFields": true 49 | }, 50 | { 51 | "name": "org.apache.commons.logging.LogFactory", 52 | "allDeclaredConstructors": true, 53 | "allPublicConstructors": true, 54 | "allDeclaredMethods": true, 55 | "allPublicMethods": true, 56 | "allDeclaredClasses": true, 57 | "allPublicClasses": true 58 | } 59 | ] -------------------------------------------------------------------------------- /google-http-client-apache-v5/src/main/java/com/google/api/client/http/apache/v5/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** HTTP Transport library for Google API's based on Apache HTTP Client/Core version 5.x */ 16 | package com.google.api.client.http.apache.v5; 17 | -------------------------------------------------------------------------------- /google-http-client-apache-v5/src/test/java/com/google/api/client/http/apache/v5/Apache5HttpResponseTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.http.apache.v5; 16 | 17 | import static org.junit.Assert.assertNotNull; 18 | 19 | import java.io.InputStream; 20 | import org.apache.hc.client5.http.classic.methods.HttpPost; 21 | import org.apache.hc.client5.http.classic.methods.HttpUriRequestBase; 22 | import org.junit.Test; 23 | 24 | public class Apache5HttpResponseTest { 25 | @Test 26 | public void testNullContent() throws Exception { 27 | HttpUriRequestBase base = new HttpPost("http://www.google.com"); 28 | MockClassicHttpResponse mockResponse = new MockClassicHttpResponse(); 29 | mockResponse.setEntity(null); 30 | Apache5HttpResponse response = new Apache5HttpResponse(base, mockResponse); 31 | 32 | InputStream content = response.getContent(); 33 | 34 | assertNotNull(content); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /google-http-client-apache-v5/src/test/java/com/google/api/client/http/apache/v5/Apache5ResponseContentTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.http.apache.v5; 16 | 17 | import java.io.IOException; 18 | import java.io.InputStream; 19 | import org.junit.Test; 20 | 21 | public class Apache5ResponseContentTest { 22 | @Test 23 | public void testNullResponseContent_doesNotThrowExceptionOnClose() throws Exception { 24 | Apache5ResponseContent response = 25 | new Apache5ResponseContent( 26 | new InputStream() { 27 | @Override 28 | public int read() throws IOException { 29 | return 0; 30 | } 31 | }, 32 | null); 33 | 34 | response.close(); 35 | } 36 | 37 | @Test 38 | public void testNullWrappedContent_doesNotThrowExceptionOnClose() throws Exception { 39 | MockClassicHttpResponse mockResponse = new MockClassicHttpResponse(); 40 | Apache5ResponseContent response = new Apache5ResponseContent(null, mockResponse); 41 | 42 | response.close(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /google-http-client-appengine/src/main/java/com/google/api/client/extensions/appengine/datastore/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * Support for the App Engine data store. 17 | * 18 | * @since 1.15 19 | * @author Yaniv Inbar 20 | */ 21 | package com.google.api.client.extensions.appengine.datastore; 22 | -------------------------------------------------------------------------------- /google-http-client-appengine/src/main/java/com/google/api/client/extensions/appengine/http/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * HTTP Transport library for Google API's based on URL Fetch in Google 18 | * App Engine. 19 | * 20 | * @since 1.10 21 | * @author Yaniv Inbar 22 | */ 23 | package com.google.api.client.extensions.appengine.http; 24 | -------------------------------------------------------------------------------- /google-http-client-appengine/src/main/resources/META-INF/native-image/com.google.http-client/google-http-client-appengine/reflect-config.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "com.google.apphosting.api.DatastorePb$DeleteRequest", 4 | "methods": [ 5 | { 6 | "name": "", 7 | "parameterTypes": [] 8 | } 9 | ] 10 | }, 11 | { 12 | "name": "com.google.apphosting.api.DatastorePb$GetRequest", 13 | "methods": [ 14 | { 15 | "name": "", 16 | "parameterTypes": [] 17 | } 18 | ] 19 | }, 20 | { 21 | "name": "com.google.apphosting.api.DatastorePb$NextRequest", 22 | "methods": [ 23 | { 24 | "name": "", 25 | "parameterTypes": [] 26 | } 27 | ] 28 | }, 29 | { 30 | "name": "com.google.apphosting.api.DatastorePb$PutRequest", 31 | "methods": [ 32 | { 33 | "name": "", 34 | "parameterTypes": [] 35 | } 36 | ] 37 | }, 38 | { 39 | "name": "com.google.apphosting.api.DatastorePb$Query", 40 | "methods": [ 41 | { 42 | "name": "", 43 | "parameterTypes": [] 44 | } 45 | ] 46 | } 47 | ] 48 | -------------------------------------------------------------------------------- /google-http-client-appengine/src/test/java/com/google/api/client/extensions/appengine/datastore/AppEngineDataStoreFactoryTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.extensions.appengine.datastore; 16 | 17 | import com.google.api.client.test.util.store.AbstractDataStoreFactoryTest; 18 | import com.google.api.client.util.store.DataStoreFactory; 19 | import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig; 20 | import com.google.appengine.tools.development.testing.LocalServiceTestHelper; 21 | 22 | /** 23 | * Tests {@link AppEngineDataStoreFactory}. 24 | * 25 | * @author Yaniv Inbar 26 | */ 27 | public class AppEngineDataStoreFactoryTest extends AbstractDataStoreFactoryTest { 28 | 29 | private final LocalServiceTestHelper helper = 30 | new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig()); 31 | 32 | @Override 33 | public void setUp() throws Exception { 34 | super.setUp(); 35 | helper.setUp(); 36 | } 37 | 38 | @Override 39 | public void tearDown() throws Exception { 40 | super.tearDown(); 41 | helper.tearDown(); 42 | } 43 | 44 | @Override 45 | protected DataStoreFactory newDataStoreFactory() { 46 | return AppEngineDataStoreFactory.getDefaultInstance(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /google-http-client-appengine/src/test/java/com/google/api/client/extensions/appengine/datastore/AppEngineNoMemcacheDataStoreFactoryTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.extensions.appengine.datastore; 16 | 17 | import com.google.api.client.util.store.DataStoreFactory; 18 | 19 | /** 20 | * Tests {@link AppEngineDataStoreFactory} with {@link 21 | * AppEngineDataStoreFactory.Builder#setDisableMemcache(boolean)}. 22 | * 23 | * @author Yaniv Inbar 24 | */ 25 | public class AppEngineNoMemcacheDataStoreFactoryTest extends AppEngineDataStoreFactoryTest { 26 | 27 | @Override 28 | protected DataStoreFactory newDataStoreFactory() { 29 | return new AppEngineDataStoreFactory.Builder().setDisableMemcache(true).build(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /google-http-client-appengine/src/test/java/com/google/api/client/extensions/appengine/http/UrlFetchTransportTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.extensions.appengine.http; 16 | 17 | import junit.framework.TestCase; 18 | import org.junit.Test; 19 | import org.junit.runner.RunWith; 20 | import org.junit.runners.JUnit4; 21 | 22 | /** 23 | * Tests {@link UrlFetchTransport}. 24 | * 25 | * @author Tony Aiuto 26 | */ 27 | @RunWith(JUnit4.class) 28 | public class UrlFetchTransportTest extends TestCase { 29 | 30 | @Test 31 | public void test() { 32 | new UrlFetchTransport(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /google-http-client-appengine/src/test/resources/META-INF/native-image/com.google.http-client/google-http-client-appengine/native-image.properties: -------------------------------------------------------------------------------- 1 | Args=--initialize-at-build-time=org.junit.runner.RunWith,java.lang.annotation.Annotation \ 2 | -------------------------------------------------------------------------------- /google-http-client-assembly/licenses/BSD-LICENSE.txt: -------------------------------------------------------------------------------- 1 | BSD License 2 | 3 | Copyright (c) 2000-2006, www.hamcrest.org 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | Redistributions of source code must retain the above copyright notice, this list of 10 | conditions and the following disclaimer. Redistributions in binary form must reproduce 11 | the above copyright notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the distribution. 13 | 14 | Neither the name of Hamcrest nor the names of its contributors may be used to endorse 15 | or promote products derived from this software without specific prior written 16 | permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 21 | SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 23 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 24 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY 26 | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 27 | DAMAGE. 28 | -------------------------------------------------------------------------------- /google-http-client-assembly/licenses/CDDL-LICENSE.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleapis/google-http-java-client/0d1726114ca678d8a9c8e3e231e0ab7205eb8395/google-http-client-assembly/licenses/CDDL-LICENSE.txt -------------------------------------------------------------------------------- /google-http-client-assembly/proguard-google-http-client.txt: -------------------------------------------------------------------------------- 1 | # ProGuard Configuration file 2 | # 3 | # See http://proguard.sourceforge.net/index.html#manual/usage.html 4 | 5 | # Needed to keep generic types and @Key annotations accessed via reflection 6 | 7 | -keepattributes Signature,RuntimeVisibleAnnotations,AnnotationDefault 8 | 9 | -keepclassmembers class * { 10 | @com.google.api.client.util.Key ; 11 | } 12 | 13 | # Needed by google-http-client-android when linking against an older platform version 14 | 15 | -dontwarn com.google.api.client.extensions.android.** 16 | -------------------------------------------------------------------------------- /google-http-client-assembly/properties/google-http-client-android.jar.properties: -------------------------------------------------------------------------------- 1 | src=../libs-sources/google-http-client-android-${project.version}-sources.jar 2 | -------------------------------------------------------------------------------- /google-http-client-assembly/properties/google-http-client-apache-v2.jar.properties: -------------------------------------------------------------------------------- 1 | src=../libs-sources/google-http-client-apache-v2-${project.version}-sources.jar 2 | -------------------------------------------------------------------------------- /google-http-client-assembly/properties/google-http-client-gson.jar.properties: -------------------------------------------------------------------------------- 1 | src=../libs-sources/google-http-client-gson-${project.version}-sources.jar 2 | -------------------------------------------------------------------------------- /google-http-client-assembly/properties/google-http-client-jackson2.jar.properties: -------------------------------------------------------------------------------- 1 | src=../libs-sources/google-http-client-jackson2-${project.version}-sources.jar 2 | -------------------------------------------------------------------------------- /google-http-client-assembly/properties/google-http-client-protobuf.jar.properties: -------------------------------------------------------------------------------- 1 | src=../libs-sources/google-http-client-protobuf-${project.version}-sources.jar 2 | -------------------------------------------------------------------------------- /google-http-client-assembly/properties/google-http-client-xml.jar.properties: -------------------------------------------------------------------------------- 1 | src=../libs-sources/google-http-client-xml-${project.version}-sources.jar 2 | -------------------------------------------------------------------------------- /google-http-client-assembly/properties/google-http-client.jar.properties: -------------------------------------------------------------------------------- 1 | src=../libs-sources/google-http-client-${project.version}-sources.jar 2 | -------------------------------------------------------------------------------- /google-http-client-assembly/properties/gson.jar.properties: -------------------------------------------------------------------------------- 1 | src=../libs-sources/gson-${project.gson.version}-sources.jar 2 | -------------------------------------------------------------------------------- /google-http-client-assembly/properties/jackson-core.jar.properties: -------------------------------------------------------------------------------- 1 | src=../libs-sources/jackson-core-${project.jackson-core2.version}-sources.jar 2 | -------------------------------------------------------------------------------- /google-http-client-assembly/properties/protobuf-java.jar.properties: -------------------------------------------------------------------------------- 1 | src=../libs-sources/protobuf-java-${project.protobuf-java.version}-sources.jar 2 | -------------------------------------------------------------------------------- /google-http-client-bom/README.md: -------------------------------------------------------------------------------- 1 | # Google HTTP Client Library Bill of Materials 2 | 3 | The `google-http-client-bom` modules is a pom that can be used to import consistent 4 | versions of `google-http-client` components plus its dependencies. 5 | 6 | To use it in Maven, add the following to your `pom.xml`: 7 | 8 | [//]: # ({x-version-update-start:google-http-client-bom:released}) 9 | ```xml 10 | 11 | 12 | 13 | com.google.http-client 14 | google-http-client-bom 15 | 1.39.0 16 | pom 17 | import 18 | 19 | 20 | 21 | ``` 22 | [//]: # ({x-version-update-end}) 23 | 24 | ## License 25 | 26 | Apache 2.0 - See [LICENSE] for more information. 27 | 28 | [LICENSE]: https://github.com/googleapis/google-http-java-client/blob/master/LICENSE 29 | -------------------------------------------------------------------------------- /google-http-client-findbugs/google-http-client-findbugs-test/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /google-http-client-findbugs/google-http-client-findbugs-test/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | google-http-client-findbugs-test 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.m2e.core.maven2Nature 22 | 23 | 24 | -------------------------------------------------------------------------------- /google-http-client-findbugs/google-http-client-findbugs-test/src/main/java/com/google/api/client/findbugs/test/BetaClass.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.findbugs.test; 16 | 17 | import com.google.api.client.util.Beta; 18 | 19 | /** A class which annotated as {@link Beta}. */ 20 | @Beta 21 | public class BetaClass { 22 | 23 | public void method() {} 24 | 25 | @Beta 26 | public void betaMethod() { 27 | BetaClass2 exp2 = new BetaClass2(); 28 | exp2.foo(); 29 | } 30 | 31 | public BetaClass() { 32 | field = 1; 33 | betaField = 2; 34 | } 35 | 36 | int field; 37 | 38 | @Beta int betaField; 39 | 40 | @Override 41 | public String toString() { 42 | return "Field: " + field + ", Beta Field: " + betaField; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /google-http-client-findbugs/google-http-client-findbugs-test/src/main/java/com/google/api/client/findbugs/test/BetaClass2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.findbugs.test; 16 | 17 | import com.google.api.client.util.Beta; 18 | 19 | /** A class which annotated as {@link Beta}. */ 20 | @Beta 21 | public class BetaClass2 { 22 | 23 | void foo() {} 24 | } 25 | -------------------------------------------------------------------------------- /google-http-client-findbugs/google-http-client-findbugs-test/src/main/java/com/google/api/client/findbugs/test/ClassWithBetaField.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.findbugs.test; 16 | 17 | import com.google.api.client.util.Beta; 18 | 19 | /** A class which contains {@link Beta} fields. */ 20 | public class ClassWithBetaField { 21 | 22 | @Beta public int betaField; 23 | public int field; 24 | 25 | @Beta public static final int betaStaticField = 10; 26 | public static final int staticField = 20; 27 | 28 | public ClassWithBetaField() { 29 | betaField = 1; 30 | field = 2; 31 | } 32 | 33 | @Override 34 | public String toString() { 35 | return "Field: " + field + ", Beta Field: " + betaField; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /google-http-client-findbugs/google-http-client-findbugs-test/src/main/java/com/google/api/client/findbugs/test/ClassWithBetaMethod.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.findbugs.test; 16 | 17 | import com.google.api.client.util.Beta; 18 | 19 | /** A class which contains {@link Beta} methods. */ 20 | public class ClassWithBetaMethod { 21 | 22 | @Beta int betaField = 10; 23 | 24 | @Beta 25 | public void betaMethod() { 26 | BetaClass2 exp2 = new BetaClass2(); 27 | exp2.foo(); 28 | 29 | betaField = 20; 30 | } 31 | 32 | public void method() {} 33 | 34 | @Beta 35 | public static void staticBetaMethod() {} 36 | 37 | public static void staticMethod() {} 38 | 39 | @Override 40 | public String toString() { 41 | return "BetaField: " + betaField; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /google-http-client-findbugs/src/main/java/com/google/api/client/findbugs/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * Findbugs package which supports custom Google APIs Client library findbugs Plugins. 17 | * 18 | *

Usage on pom.xml: 19 | * 20 | *

21 |  * <plugin>
22 |  * <groupId>org.codehaus.mojo</groupId>
23 |  * <artifactId>findbugs-maven-plugin</artifactId>
24 |  * ...
25 |  * <configuration>
26 |  * <plugins>
27 |  * <plugin>
28 |  * <groupId>com.google.http-client</groupId>
29 |  * <artifactId>google-http-client-findbugs</artifactId>
30 |  * <version>${project.http.version}</version>
31 |  * </plugin>
32 |  * </plugins>
33 |  * </configuration>
34 |  * ...
35 |  * </plugin>
36 |  * 
37 | * 38 | * @author Eyal Peled 39 | */ 40 | package com.google.api.client.findbugs; 41 | -------------------------------------------------------------------------------- /google-http-client-findbugs/src/main/resources/bugrank.txt: -------------------------------------------------------------------------------- 1 | 10 BugPattern BETA_CLASS_USAGE 2 | 10 BugPattern BETA_METHOD_USAGE 3 | 10 BugPattern BETA_FIELD_USAGE -------------------------------------------------------------------------------- /google-http-client-findbugs/src/main/resources/findbugs.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 8 | 9 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /google-http-client-gson/src/main/java/com/google/api/client/json/gson/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * Low-level implementation of the GSON parser library based on the GSON JSON library. 18 | * 19 | * @since 1.3 20 | * @author Yaniv Inbar 21 | */ 22 | package com.google.api.client.json.gson; 23 | -------------------------------------------------------------------------------- /google-http-client-gson/src/main/resources/META-INF/native-image/com.google.http-client/google-http-client-gson/reflect-config.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "com.google.api.client.json.GenericJson", 4 | "queryAllDeclaredConstructors": true, 5 | "queryAllPublicConstructors": true, 6 | "queryAllDeclaredMethods": true, 7 | "allDeclaredConstructors": true, 8 | "allPublicConstructors": true, 9 | "allPublicMethods": true, 10 | "allDeclaredFields": true 11 | }, 12 | { 13 | "name": "com.google.api.client.util.ArrayMap", 14 | "queryAllDeclaredConstructors": true, 15 | "queryAllPublicConstructors": true, 16 | "queryAllDeclaredMethods": true, 17 | "allDeclaredConstructors": true, 18 | "allPublicConstructors": true, 19 | "allPublicMethods": true, 20 | "allDeclaredFields": true 21 | } 22 | ] -------------------------------------------------------------------------------- /google-http-client-gson/src/test/java/com/google/api/client/json/gson/GsonGeneratorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.json.gson; 16 | 17 | import com.google.api.client.json.JsonGenerator; 18 | import com.google.api.client.test.json.AbstractJsonGeneratorTest; 19 | import java.io.IOException; 20 | import java.io.Writer; 21 | 22 | public class GsonGeneratorTest extends AbstractJsonGeneratorTest { 23 | 24 | private static final GsonFactory FACTORY = new GsonFactory(); 25 | 26 | @Override 27 | protected JsonGenerator newGenerator(Writer writer) throws IOException { 28 | return FACTORY.createJsonGenerator(writer); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /google-http-client-gson/src/test/java/com/google/api/client/json/gson/GsonParserTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2019 Google LLC 3 | * 4 | *

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 5 | * except in compliance with the License. You may obtain a copy of the License at 6 | * 7 | *

https://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | *

Unless required by applicable law or agreed to in writing, software distributed under the 10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 11 | * express or implied. See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package com.google.api.client.json.gson; 15 | 16 | import com.google.api.client.json.JsonFactory; 17 | import com.google.api.client.test.json.AbstractJsonParserTest; 18 | 19 | public class GsonParserTest extends AbstractJsonParserTest { 20 | 21 | @Override 22 | protected JsonFactory newJsonFactory() { 23 | return new GsonFactory(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /google-http-client-gson/src/test/resources/META-INF/native-image/com.google.http-client/google-http-client-gson/native-image.properties: -------------------------------------------------------------------------------- 1 | Args=--initialize-at-build-time=org.junit.runner.RunWith,java.lang.annotation.Annotation 2 | -------------------------------------------------------------------------------- /google-http-client-jackson2/src/main/java/com/google/api/client/json/jackson2/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * Low-level implementation of the JSON parser library based on the Jackson 2 JSON library. 17 | * 18 | * @since 1.11 19 | * @author Yaniv Inbar 20 | */ 21 | package com.google.api.client.json.jackson2; 22 | -------------------------------------------------------------------------------- /google-http-client-jackson2/src/main/resources/META-INF/native-image/com.google.http-client/google-http-client-jackson2/reflect-config.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "com.google.api.client.json.GenericJson", 4 | "queryAllDeclaredConstructors": true, 5 | "queryAllPublicConstructors": true, 6 | "queryAllDeclaredMethods": true, 7 | "allDeclaredConstructors": true, 8 | "allPublicConstructors": true, 9 | "allPublicMethods": true, 10 | "allDeclaredFields": true 11 | }, 12 | { 13 | "name": "java.util.HashMap", 14 | "queryAllDeclaredConstructors": true, 15 | "queryAllPublicConstructors": true, 16 | "queryAllDeclaredMethods": true, 17 | "allDeclaredConstructors": true, 18 | "allPublicConstructors": true, 19 | "allPublicMethods": true, 20 | "allDeclaredFields": true 21 | }, 22 | { 23 | "name": "java.util.LinkedList", 24 | "queryAllDeclaredConstructors": true, 25 | "queryAllPublicConstructors": true, 26 | "queryAllDeclaredMethods": true, 27 | "allDeclaredConstructors": true, 28 | "allPublicConstructors": true, 29 | "allPublicMethods": true, 30 | "allDeclaredFields": true 31 | }, 32 | { 33 | "name": "java.lang.Object", 34 | "queryAllDeclaredConstructors": true, 35 | "queryAllPublicConstructors": true, 36 | "queryAllDeclaredMethods": true, 37 | "allDeclaredConstructors": true, 38 | "allPublicConstructors": true, 39 | "allPublicMethods": true, 40 | "allDeclaredFields": true 41 | }, 42 | { 43 | "name": "com.google.api.client.util.ArrayMap", 44 | "queryAllDeclaredConstructors": true, 45 | "queryAllPublicConstructors": true, 46 | "queryAllDeclaredMethods": true, 47 | "allDeclaredConstructors": true, 48 | "allPublicConstructors": true, 49 | "allPublicMethods": true, 50 | "allDeclaredFields": true 51 | } 52 | ] -------------------------------------------------------------------------------- /google-http-client-jackson2/src/test/java/com/google/api/client/json/jackson2/JacksonGeneratorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.json.jackson2; 16 | 17 | import com.google.api.client.json.JsonGenerator; 18 | import com.google.api.client.test.json.AbstractJsonGeneratorTest; 19 | import java.io.IOException; 20 | import java.io.Writer; 21 | 22 | public class JacksonGeneratorTest extends AbstractJsonGeneratorTest { 23 | 24 | private static final JacksonFactory FACTORY = new JacksonFactory(); 25 | 26 | @Override 27 | protected JsonGenerator newGenerator(Writer writer) throws IOException { 28 | return FACTORY.createJsonGenerator(writer); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /google-http-client-jackson2/src/test/java/com/google/api/client/json/jackson2/JacksonParserTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2019 Google LLC 3 | * 4 | *

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 5 | * except in compliance with the License. You may obtain a copy of the License at 6 | * 7 | *

https://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | *

Unless required by applicable law or agreed to in writing, software distributed under the 10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 11 | * express or implied. See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package com.google.api.client.json.jackson2; 15 | 16 | import com.google.api.client.json.JsonFactory; 17 | import com.google.api.client.test.json.AbstractJsonParserTest; 18 | 19 | public class JacksonParserTest extends AbstractJsonParserTest { 20 | 21 | @Override 22 | protected JsonFactory newJsonFactory() { 23 | return new JacksonFactory(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /google-http-client-jackson2/src/test/resources/META-INF/native-image/com.google.http-client/google-http-client-jackson2/native-image.properties: -------------------------------------------------------------------------------- 1 | Args=--initialize-at-build-time=com.google.api.client.json.jackson2.JacksonFactoryTest \ 2 | --initialize-at-build-time=com.google.api.client.json.jackson2.JacksonGeneratorTest \ 3 | --initialize-at-build-time=com.google.api.client.json.jackson2.JacksonFactory \ 4 | --initialize-at-build-time=com.google.api.client.util.StringUtils \ 5 | --initialize-at-build-time=com.fasterxml.jackson.core \ 6 | --initialize-at-build-time=org.junit.runner.RunWith,java.lang.annotation.Annotation -------------------------------------------------------------------------------- /google-http-client-protobuf/src/main/java/com/google/api/client/http/protobuf/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * {@link com.google.api.client.util.Beta}
17 | * HTTP utilities for the Protocol Buffer 18 | * format based on the pluggable HTTP library. 19 | * 20 | * @since 1.5 21 | * @author Yaniv Inbar 22 | */ 23 | @com.google.api.client.util.Beta 24 | package com.google.api.client.http.protobuf; 25 | -------------------------------------------------------------------------------- /google-http-client-protobuf/src/main/java/com/google/api/client/protobuf/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * {@link com.google.api.client.util.Beta}
17 | * Utilities for the Protocol Buffer 18 | * format. 19 | * 20 | * @since 1.5 21 | * @author Yaniv Inbar 22 | */ 23 | @com.google.api.client.util.Beta 24 | package com.google.api.client.protobuf; 25 | -------------------------------------------------------------------------------- /google-http-client-protobuf/src/main/resources/META-INF/native-image/com.google.http-client/google-http-client-protobuf/native-image.properties: -------------------------------------------------------------------------------- 1 | Args=--initialize-at-build-time=org.junit.runner.RunWith,java.lang.annotation.Annotation 2 | -------------------------------------------------------------------------------- /google-http-client-protobuf/src/main/resources/META-INF/native-image/com.google.http-client/google-http-client-protobuf/reflect-config.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "com.google.api.client.protobuf.SimpleProto$TestMessage", 4 | "queryAllDeclaredConstructors": true, 5 | "queryAllPublicConstructors": true, 6 | "queryAllDeclaredMethods": true, 7 | "allDeclaredConstructors": true, 8 | "allPublicConstructors": true, 9 | "allPublicMethods": true, 10 | "allDeclaredFields": true 11 | } 12 | ] -------------------------------------------------------------------------------- /google-http-client-protobuf/src/test/proto/simple_proto.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | syntax = "proto2"; 16 | option optimize_for = LITE_RUNTIME; 17 | option java_package = "com.google.api.client.protobuf"; 18 | 19 | message TestMessage { 20 | required TestStatus status = 1; 21 | required string name = 2; 22 | required int64 value = 3; 23 | } 24 | 25 | enum TestStatus { 26 | SUCCESS = 1; 27 | FAILURE = 2; 28 | } -------------------------------------------------------------------------------- /google-http-client-test/src/main/java/com/google/api/client/test/json/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * Classes used for testing of JSON library implementations. 17 | * 18 | * @author Ravi Mistry 19 | */ 20 | package com.google.api.client.test.json; 21 | -------------------------------------------------------------------------------- /google-http-client-test/src/main/java/com/google/api/client/test/util/store/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * Abstract tests for data stores. 17 | * 18 | * @author Yaniv Inbar 19 | */ 20 | package com.google.api.client.test.util.store; 21 | -------------------------------------------------------------------------------- /google-http-client-test/src/main/resources/META-INF/native-image/com.google.http-client/google-http-client-test/native-image.properties: -------------------------------------------------------------------------------- 1 | Args=--initialize-at-build-time=org.junit.runner.RunWith,java.lang.annotation.Annotation 2 | -------------------------------------------------------------------------------- /google-http-client-test/src/main/resources/META-INF/native-image/com.google.http-client/google-http-client-test/serialization-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "types":[ 3 | {"name":"java.lang.String" 4 | }, 5 | {"name":"java.lang.Boolean"}, 6 | {"name":"java.util.HashMap"} 7 | ], 8 | "lambdaCapturingTypes":[ 9 | ], 10 | "proxies":[ 11 | ] 12 | } -------------------------------------------------------------------------------- /google-http-client-test/src/test/java/com/google/api/client/test/util/store/MemoryDataStoreFactoryTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.test.util.store; 16 | 17 | import com.google.api.client.util.store.DataStoreFactory; 18 | import com.google.api.client.util.store.MemoryDataStoreFactory; 19 | import org.junit.runner.RunWith; 20 | import org.junit.runners.JUnit4; 21 | 22 | /** 23 | * Tests {@link MemoryDataStoreFactory}. 24 | * 25 | * @author Yaniv Inbar 26 | */ 27 | @RunWith(JUnit4.class) 28 | public class MemoryDataStoreFactoryTest extends AbstractDataStoreFactoryTest { 29 | 30 | @Override 31 | protected DataStoreFactory newDataStoreFactory() { 32 | return MemoryDataStoreFactory.getDefaultInstance(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /google-http-client-xml/src/main/java/com/google/api/client/http/xml/atom/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * {@link com.google.api.client.util.Beta}
17 | * Atom XML HTTP library based on the pluggable HTTP library. 18 | * 19 | * @since 1.4 20 | * @author Yaniv Inbar 21 | */ 22 | @com.google.api.client.util.Beta 23 | package com.google.api.client.http.xml.atom; 24 | -------------------------------------------------------------------------------- /google-http-client-xml/src/main/java/com/google/api/client/http/xml/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * {@link com.google.api.client.util.Beta}
17 | * XML HTTP library based on the pluggable HTTP library. 18 | * 19 | * @since 1.3 20 | * @author Yaniv Inbar 21 | */ 22 | @com.google.api.client.util.Beta 23 | package com.google.api.client.http.xml; 24 | -------------------------------------------------------------------------------- /google-http-client-xml/src/main/java/com/google/api/client/xml/atom/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * {@link com.google.api.client.util.Beta}
17 | * Utilities for Atom XML. 18 | * 19 | * @since 1.0 20 | * @author Yaniv Inbar 21 | */ 22 | @com.google.api.client.util.Beta 23 | package com.google.api.client.xml.atom; 24 | -------------------------------------------------------------------------------- /google-http-client-xml/src/main/java/com/google/api/client/xml/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * {@link com.google.api.client.util.Beta}
17 | * Utilities for XML. 18 | * 19 | * @since 1.0 20 | * @author Yaniv Inbar 21 | */ 22 | @com.google.api.client.util.Beta 23 | package com.google.api.client.xml; 24 | -------------------------------------------------------------------------------- /google-http-client-xml/src/main/resources/META-INF/native-image/com.google.http-client/google-http-client-xml/reflect-config.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "com.google.api.client.xml.GenericXml", 4 | "queryAllDeclaredConstructors": true, 5 | "queryAllPublicConstructors": true, 6 | "queryAllDeclaredMethods": true, 7 | "allDeclaredConstructors": true, 8 | "allPublicConstructors": true, 9 | "allPublicMethods": true, 10 | "allDeclaredFields": true 11 | } 12 | ] -------------------------------------------------------------------------------- /google-http-client-xml/src/test/resources/META-INF/native-image/com.google.http-client/google-http-client-xml/native-image.properties: -------------------------------------------------------------------------------- 1 | Args=--initialize-at-build-time=org.junit.runner.RunWith,java.lang.annotation.Annotation 2 | -------------------------------------------------------------------------------- /google-http-client-xml/src/test/resources/META-INF/native-image/com.google.http-client/google-http-client-xml/resource-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "resources":[ 3 | {"pattern":"\\Qsample-atom.xml\\E"}], 4 | "bundles":[] 5 | } -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/http/ConsumingInputStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.api.client.http; 18 | 19 | import com.google.common.io.ByteStreams; 20 | import java.io.FilterInputStream; 21 | import java.io.IOException; 22 | import java.io.InputStream; 23 | 24 | /** 25 | * This class in meant to wrap an {@link InputStream} so that all bytes in the steam are read and 26 | * discarded on {@link InputStream#close()}. This ensures that the underlying connection has the 27 | * option to be reused. 28 | */ 29 | final class ConsumingInputStream extends FilterInputStream { 30 | private boolean closed = false; 31 | 32 | ConsumingInputStream(InputStream inputStream) { 33 | super(inputStream); 34 | } 35 | 36 | @Override 37 | public void close() throws IOException { 38 | if (!closed && in != null) { 39 | try { 40 | ByteStreams.exhaust(this); 41 | super.in.close(); 42 | } finally { 43 | this.closed = true; 44 | } 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/http/EmptyContent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.http; 16 | 17 | import java.io.IOException; 18 | import java.io.OutputStream; 19 | 20 | /** 21 | * Empty HTTP content of length zero just to force {@link HttpRequest#execute()} to add the header 22 | * {@code Content-Length: 0}. 23 | * 24 | *

Note that there is no {@code Content-Length} header if the HTTP request content is {@code 25 | * null} . However, when making a request like PUT or POST without a {@code Content-Length} header, 26 | * some servers may respond with a {@code 411 Length Required} error. Specifying the {@code 27 | * Content-Length: 0} header may work around that problem. 28 | * 29 | * @since 1.11 30 | * @author Yaniv Inbar 31 | */ 32 | public class EmptyContent implements HttpContent { 33 | 34 | public long getLength() throws IOException { 35 | return 0; 36 | } 37 | 38 | public String getType() { 39 | return null; 40 | } 41 | 42 | public void writeTo(OutputStream out) throws IOException { 43 | out.flush(); 44 | } 45 | 46 | public boolean retrySupported() { 47 | return true; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/http/GZipEncoding.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.http; 16 | 17 | import com.google.api.client.util.StreamingContent; 18 | import java.io.BufferedOutputStream; 19 | import java.io.IOException; 20 | import java.io.OutputStream; 21 | import java.util.zip.GZIPOutputStream; 22 | 23 | /** 24 | * GZip HTTP content encoding. 25 | * 26 | * @since 1.14 27 | * @author Yaniv Inbar 28 | */ 29 | public class GZipEncoding implements HttpEncoding { 30 | 31 | @Override 32 | public String getName() { 33 | return "gzip"; 34 | } 35 | 36 | @Override 37 | public void encode(StreamingContent content, OutputStream out) throws IOException { 38 | // must not close the underlying output stream 39 | OutputStream out2 = 40 | new BufferedOutputStream(out) { 41 | @Override 42 | public void close() throws IOException { 43 | // copy implementation of super.close(), except do not close the underlying output 44 | // stream 45 | try { 46 | flush(); 47 | } catch (IOException ignored) { 48 | // fall through 49 | } 50 | } 51 | }; 52 | GZIPOutputStream zipper = new GZIPOutputStream(out2); 53 | content.writeTo(zipper); 54 | // cannot call just zipper.finish() because that would cause a severe memory leak 55 | zipper.close(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/http/HttpContent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.http; 16 | 17 | import com.google.api.client.util.StreamingContent; 18 | import java.io.IOException; 19 | import java.io.OutputStream; 20 | 21 | /** 22 | * Serializes HTTP request content into an output stream. 23 | * 24 | *

Implementations don't need to be thread-safe. 25 | * 26 | * @since 1.0 27 | * @author Yaniv Inbar 28 | */ 29 | public interface HttpContent extends StreamingContent { 30 | 31 | /** Returns the content length or less than zero if not known. */ 32 | long getLength() throws IOException; 33 | 34 | /** Returns the content type or {@code null} for none. */ 35 | String getType(); 36 | 37 | /** 38 | * Returns whether or not retry is supported on this content type. 39 | * 40 | * @since 1.4 41 | */ 42 | boolean retrySupported(); 43 | 44 | void writeTo(OutputStream out) throws IOException; 45 | } 46 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/http/HttpEncoding.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.http; 16 | 17 | import com.google.api.client.util.StreamingContent; 18 | import java.io.IOException; 19 | import java.io.OutputStream; 20 | 21 | /** 22 | * HTTP content encoding. 23 | * 24 | *

Implementations don't need to be thread-safe. 25 | * 26 | * @since 1.14 27 | * @author Yaniv Inbar 28 | */ 29 | public interface HttpEncoding { 30 | 31 | /** Returns the content encoding name (for example {@code "gzip"}) or {@code null} for none. */ 32 | String getName(); 33 | 34 | /** 35 | * Encodes the streaming content into the output stream. 36 | * 37 | *

Implementations must not close the output stream, and instead should flush the output 38 | * stream. Some callers may assume that the output stream has not been closed, and will fail to 39 | * work if it has been closed. 40 | * 41 | * @param content streaming content 42 | * @param out output stream 43 | */ 44 | void encode(StreamingContent content, OutputStream out) throws IOException; 45 | } 46 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/http/HttpMethods.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 3 | * in compliance with the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License 8 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 9 | * or implied. See the License for the specific language governing permissions and limitations under 10 | * the License. 11 | */ 12 | 13 | package com.google.api.client.http; 14 | 15 | /** 16 | * HTTP request method constants specified in RFC 2616 Section 5.1.1. 18 | * 19 | * @since 1.12 20 | * @author Yaniv Inbar 21 | */ 22 | public final class HttpMethods { 23 | 24 | /** HTTP CONNECT method. */ 25 | public static final String CONNECT = "CONNECT"; 26 | 27 | /** HTTP DELETE method. */ 28 | public static final String DELETE = "DELETE"; 29 | 30 | /** HTTP GET method. */ 31 | public static final String GET = "GET"; 32 | 33 | /** HTTP HEAD method. */ 34 | public static final String HEAD = "HEAD"; 35 | 36 | /** HTTP OPTIONS method. */ 37 | public static final String OPTIONS = "OPTIONS"; 38 | 39 | /** 40 | * HTTP PATCH method. 41 | * 42 | * @since 1.14 43 | */ 44 | public static final String PATCH = "PATCH"; 45 | 46 | /** HTTP POST method. */ 47 | public static final String POST = "POST"; 48 | 49 | /** HTTP PUT method. */ 50 | public static final String PUT = "PUT"; 51 | 52 | /** HTTP TRACE method. */ 53 | public static final String TRACE = "TRACE"; 54 | 55 | private HttpMethods() {} 56 | } 57 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/http/apache/HttpExtensionMethod.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 3 | * in compliance with the License. You may obtain a copy of the License at 4 | * 5 | * http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License 8 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 9 | * or implied. See the License for the specific language governing permissions and limitations under 10 | * the License. 11 | */ 12 | 13 | package com.google.api.client.http.apache; 14 | 15 | import com.google.api.client.util.Preconditions; 16 | import java.net.URI; 17 | import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; 18 | 19 | /** 20 | * HTTP extension method. 21 | * 22 | * @author Yaniv Inbar 23 | */ 24 | final class HttpExtensionMethod extends HttpEntityEnclosingRequestBase { 25 | 26 | /** Request method name. */ 27 | private final String methodName; 28 | 29 | /** 30 | * @param methodName request method name 31 | * @param uri URI 32 | */ 33 | public HttpExtensionMethod(String methodName, String uri) { 34 | this.methodName = Preconditions.checkNotNull(methodName); 35 | setURI(URI.create(uri)); 36 | } 37 | 38 | @Override 39 | public String getMethod() { 40 | return methodName; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/http/apache/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * HTTP Transport library for Google API's based on Apache HTTP Client version 4. 17 | * 18 | * @since 1.0 19 | * @author Yaniv Inbar 20 | * @deprecated Please use com.google.api.client.http.apache.v2 provided by the 21 | * com.google.http-client:google-http-client-apache-v2 artifact. 22 | */ 23 | package com.google.api.client.http.apache; 24 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/http/javanet/ConnectionFactory.java: -------------------------------------------------------------------------------- 1 | package com.google.api.client.http.javanet; 2 | 3 | import java.io.IOException; 4 | import java.net.HttpURLConnection; 5 | import java.net.URL; 6 | 7 | /** Given a {@link URL} instance, produces an {@link HttpURLConnection}. */ 8 | public interface ConnectionFactory { 9 | 10 | /** 11 | * Creates a new {@link HttpURLConnection} from the given {@code url}. 12 | * 13 | * @param url the URL to which the connection will be made 14 | * @return the created connection object, which will still be in the pre-connected state 15 | * @throws IOException if there was a problem producing the connection 16 | * @throws ClassCastException if the URL is not for an HTTP endpoint 17 | */ 18 | HttpURLConnection openConnection(URL url) throws IOException, ClassCastException; 19 | } 20 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/http/javanet/DefaultConnectionFactory.java: -------------------------------------------------------------------------------- 1 | package com.google.api.client.http.javanet; 2 | 3 | import java.io.IOException; 4 | import java.net.HttpURLConnection; 5 | import java.net.Proxy; 6 | import java.net.URL; 7 | 8 | /** 9 | * Default implementation of {@link ConnectionFactory}, which simply attempts to open the connection 10 | * with an optional {@link Proxy}. 11 | */ 12 | public class DefaultConnectionFactory implements ConnectionFactory { 13 | 14 | private final Proxy proxy; 15 | 16 | public DefaultConnectionFactory() { 17 | this(null); 18 | } 19 | 20 | /** 21 | * @param proxy HTTP proxy or {@code null} to use the proxy settings from 23 | * system properties 24 | */ 25 | public DefaultConnectionFactory(Proxy proxy) { 26 | this.proxy = proxy; 27 | } 28 | 29 | @Override 30 | public HttpURLConnection openConnection(URL url) throws IOException { 31 | return (HttpURLConnection) (proxy == null ? url.openConnection() : url.openConnection(proxy)); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/http/javanet/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * HTTP Transport library for Google API's based on the {@code java.net} package. 17 | * 18 | * @since 1.0 19 | * @author Yaniv Inbar 20 | */ 21 | package com.google.api.client.http.javanet; 22 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/http/json/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * JSON HTTP library based on the pluggable HTTP library. 17 | * 18 | * @since 1.0 19 | * @author Yaniv Inbar 20 | */ 21 | package com.google.api.client.http.json; 22 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/http/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * Subset of HTTP 1.1 needed from the specification in RFC 2616: Hypertext Transfer Protocol -- HTTP/1.1. 18 | * 19 | * @since 1.0 20 | * @author Yaniv Inbar 21 | */ 22 | package com.google.api.client.http; 23 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/json/Json.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.json; 16 | 17 | /** 18 | * JSON utilities. 19 | * 20 | * @since 1.0 21 | * @author Yaniv Inbar 22 | */ 23 | public class Json { 24 | 25 | /** 26 | * {@code "application/json; charset=utf-8"} media type used as a default for JSON parsing. 27 | * 28 | *

Use {@link com.google.api.client.http.HttpMediaType#equalsIgnoreParameters} for comparing 29 | * media types. 30 | * 31 | * @since 1.10 32 | */ 33 | public static final String MEDIA_TYPE = "application/json; charset=UTF-8"; 34 | } 35 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/json/JsonToken.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.json; 16 | 17 | /** 18 | * JSON token in the low-level JSON library. 19 | * 20 | * @since 1.3 21 | * @author Yaniv Inbar 22 | */ 23 | public enum JsonToken { 24 | 25 | /** Start of a JSON array ('['). */ 26 | START_ARRAY, 27 | 28 | /** End of a JSON array (']'). */ 29 | END_ARRAY, 30 | 31 | /** Start of a JSON object ('{'). */ 32 | START_OBJECT, 33 | 34 | /** End of a JSON object ('}'). */ 35 | END_OBJECT, 36 | 37 | /** JSON field name. */ 38 | FIELD_NAME, 39 | 40 | /** JSON field string value. */ 41 | VALUE_STRING, 42 | 43 | /** 44 | * JSON field number value of an integer with an arbitrary number of digits and no fractional 45 | * part. 46 | */ 47 | VALUE_NUMBER_INT, 48 | 49 | /** JSON field number value of an arbitrary-precision decimal number. */ 50 | VALUE_NUMBER_FLOAT, 51 | 52 | /** JSON field {@code true} value. */ 53 | VALUE_TRUE, 54 | 55 | /** JSON field {@code false} value. */ 56 | VALUE_FALSE, 57 | 58 | /** JSON {@code null}. */ 59 | VALUE_NULL, 60 | 61 | /** Some other token. */ 62 | NOT_AVAILABLE 63 | } 64 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/json/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * Utilities for JSON as specified in RFC 4627: The 17 | * application/json Media Type for JavaScript Object Notation (JSON) and Introducing JSON. 19 | * 20 | * @since 1.0 21 | * @author Yaniv Inbar 22 | */ 23 | @ReflectionSupport(value = ReflectionSupport.Level.FULL) 24 | package com.google.api.client.json; 25 | 26 | import com.google.j2objc.annotations.ReflectionSupport; 27 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/json/rpc2/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * {@link com.google.api.client.util.Beta}
17 | * JSON-RPC 2.0 as specified in JSON-RPC 2.0 Specification 19 | * and JSON-RPC over 20 | * HTTP . 21 | * 22 | * @since 1.0 23 | * @author Yaniv Inbar 24 | */ 25 | @com.google.api.client.util.Beta 26 | package com.google.api.client.json.rpc2; 27 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/json/webtoken/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * {@link com.google.api.client.util.Beta}
17 | * JSON Web Token (JWT) 18 | * and JSON Web Signature 19 | * (JWS). 20 | * 21 | * @since 1.14 (since 1.7 as com.google.api.client.auth.jsontoken) 22 | * @author Yaniv Inbar 23 | */ 24 | package com.google.api.client.json.webtoken; 25 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/testing/http/FixedClock.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.testing.http; 16 | 17 | import com.google.api.client.util.Beta; 18 | import com.google.api.client.util.Clock; 19 | import java.util.concurrent.atomic.AtomicLong; 20 | 21 | /** 22 | * {@link Beta}
23 | * A thread-safe fixed time implementation of the Clock to be used for unit testing. 24 | * 25 | *

Explicitly allows you to set the time to any arbitrary value. 26 | * 27 | * @since 1.9 28 | * @author mlinder@google.com (Matthias Linder) 29 | */ 30 | @Beta 31 | public class FixedClock implements Clock { 32 | private AtomicLong currentTime; 33 | 34 | /** Initializes the FixedClock with 0 millis as start time. */ 35 | public FixedClock() { 36 | this(0L); 37 | } 38 | 39 | /** 40 | * Initializes the FixedClock with the specified time. 41 | * 42 | * @param startTime time in milliseconds used for initialization. 43 | */ 44 | public FixedClock(long startTime) { 45 | currentTime = new AtomicLong(startTime); 46 | } 47 | 48 | /** 49 | * Changes the time value this time provider is returning. 50 | * 51 | * @param newTime New time in milliseconds. 52 | */ 53 | public FixedClock setTime(long newTime) { 54 | currentTime.set(newTime); 55 | return this; 56 | } 57 | 58 | public long currentTimeMillis() { 59 | return currentTime.get(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/testing/http/HttpTesting.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.testing.http; 16 | 17 | import com.google.api.client.http.GenericUrl; 18 | import com.google.api.client.util.Beta; 19 | 20 | /** 21 | * {@link Beta}
22 | * Utilities and constants related to testing the HTTP library. 23 | * 24 | * @author Yaniv Inbar 25 | * @since 1.6 26 | */ 27 | @Beta 28 | public final class HttpTesting { 29 | 30 | /** A simple string URL for testing of value {@code "http://google.com/"}. */ 31 | public static final String SIMPLE_URL = "http://google.com/"; 32 | 33 | /** A simple generic URL for testing of value {@link #SIMPLE_URL}. */ 34 | public static final GenericUrl SIMPLE_GENERIC_URL = new GenericUrl(SIMPLE_URL); 35 | 36 | private HttpTesting() {} 37 | } 38 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/testing/http/apache/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * {@link com.google.api.client.util.Beta}
17 | * Testing utilities used for writing tests based on the Apache HTTP Client. 18 | * 19 | * @since 1.14 20 | * @author Yaniv Inbar 21 | */ 22 | @com.google.api.client.util.Beta 23 | package com.google.api.client.testing.http.apache; 24 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/testing/http/javanet/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * {@link com.google.api.client.util.Beta}
17 | * Testing utilities used for writing tests based on the {@code java.net} package. 18 | * 19 | * @since 1.11 20 | * @author Yaniv Inbar 21 | */ 22 | @com.google.api.client.util.Beta 23 | package com.google.api.client.testing.http.javanet; 24 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/testing/http/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * {@link com.google.api.client.util.Beta}
17 | * Testing utilities used for writing tests based on this library. 18 | * 19 | * @since 1.3 20 | * @author Yaniv Inbar 21 | */ 22 | @com.google.api.client.util.Beta 23 | package com.google.api.client.testing.http; 24 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/testing/json/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * {@link com.google.api.client.util.Beta}
17 | * Testing utilities used for writing tests based on this library. 18 | * 19 | * @since 1.15 (since 1.11 as com.google.api.client.testing.http.json) 20 | * @author rmistry@google.com (Ravi Mistry) 21 | */ 22 | @com.google.api.client.util.Beta 23 | package com.google.api.client.testing.json; 24 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/testing/json/webtoken/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * {@link com.google.api.client.util.Beta}
17 | * Testing utilities used for writing tests for JSON WebToken. 18 | * 19 | * @since 1.19.1 20 | */ 21 | @com.google.api.client.util.Beta 22 | package com.google.api.client.testing.json.webtoken; 23 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/testing/util/LogRecordingHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.testing.util; 16 | 17 | import com.google.api.client.util.Beta; 18 | import com.google.api.client.util.Lists; 19 | import java.util.List; 20 | import java.util.logging.Handler; 21 | import java.util.logging.LogRecord; 22 | 23 | /** 24 | * {@link Beta}
25 | * Logging handler that stores log records. 26 | * 27 | * @author Yaniv Inbar 28 | * @since 1.14 29 | */ 30 | @Beta 31 | public class LogRecordingHandler extends Handler { 32 | 33 | /** Stored records. */ 34 | private final List records = Lists.newArrayList(); 35 | 36 | @Override 37 | public void publish(LogRecord record) { 38 | records.add(record); 39 | } 40 | 41 | @Override 42 | public void flush() {} 43 | 44 | @Override 45 | public void close() throws SecurityException {} 46 | 47 | /** Returns a new instance of a list of published record messages. */ 48 | public List messages() { 49 | List result = Lists.newArrayList(); 50 | for (LogRecord record : records) { 51 | result.add(record.getMessage()); 52 | } 53 | return result; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/testing/util/MockSleeper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.testing.util; 16 | 17 | import com.google.api.client.util.Beta; 18 | import com.google.api.client.util.Sleeper; 19 | 20 | /** 21 | * {@link Beta}
22 | * Mock for {@link Sleeper}. 23 | * 24 | *

Implementation is not thread-safe. 25 | * 26 | * @author Yaniv Inbar 27 | * @since 1.15 28 | */ 29 | @Beta 30 | public class MockSleeper implements Sleeper { 31 | 32 | /** Number of times {@link #sleep(long)} was called. */ 33 | private int count; 34 | 35 | /** 36 | * Value of {@code millis} parameter when {@link #sleep(long)} was last called or {@code 0} if not 37 | * called. 38 | */ 39 | private long lastMillis; 40 | 41 | public void sleep(long millis) throws InterruptedException { 42 | count++; 43 | lastMillis = millis; 44 | } 45 | 46 | /** Returns the number of times {@link #sleep(long)} was called. */ 47 | public final int getCount() { 48 | return count; 49 | } 50 | 51 | /** 52 | * Returns the value of {@code millis} parameter when {@link #sleep(long)} was last called or 53 | * {@code 0} if not called. 54 | */ 55 | public final long getLastMillis() { 56 | return lastMillis; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/testing/util/TestableByteArrayOutputStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.testing.util; 16 | 17 | import com.google.api.client.util.Beta; 18 | import java.io.ByteArrayOutputStream; 19 | import java.io.IOException; 20 | 21 | /** 22 | * {@link Beta}
23 | * Testable extension for a byte array output stream. 24 | * 25 | * @author Yaniv Inbar 26 | * @since 1.14 27 | */ 28 | @Beta 29 | public class TestableByteArrayOutputStream extends ByteArrayOutputStream { 30 | 31 | /** Whether the output stream has been closed. */ 32 | private boolean closed; 33 | 34 | /** 35 | * {@inheritDoc} 36 | * 37 | *

Overriding is supported, but overriding method must call the super implementation. 38 | */ 39 | @Override 40 | public void close() throws IOException { 41 | closed = true; 42 | } 43 | 44 | /** Returns the written buffer value as a modifiable byte array. */ 45 | public final byte[] getBuffer() { 46 | return buf; 47 | } 48 | 49 | /** Returns whether the output stream has been closed. */ 50 | public final boolean isClosed() { 51 | return closed; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/testing/util/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * {@link com.google.api.client.util.Beta}
17 | * Testing utilities used for writing tests based on this library. 18 | * 19 | * @since 1.14 20 | * @author Yaniv Inbar 21 | */ 22 | @com.google.api.client.util.Beta 23 | package com.google.api.client.testing.util; 24 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/util/BackOffUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.util; 16 | 17 | import java.io.IOException; 18 | 19 | /** 20 | * {@link Beta}
21 | * Utilities for {@link BackOff}. 22 | * 23 | * @since 1.15 24 | * @author Yaniv Inbar 25 | */ 26 | @Beta 27 | public final class BackOffUtils { 28 | 29 | /** 30 | * Runs the next iteration of the back-off policy, and returns whether to continue to retry the 31 | * operation. 32 | * 33 | *

If {@code true}, it will call {@link Sleeper#sleep(long)} with the specified number of 34 | * milliseconds from {@link BackOff#nextBackOffMillis()}. 35 | * 36 | * @param sleeper sleeper 37 | * @param backOff back-off policy 38 | * @return whether to continue to back off; in other words, whether {@link 39 | * BackOff#nextBackOffMillis()} did not return {@link BackOff#STOP} 40 | * @throws InterruptedException if any thread has interrupted the current thread 41 | */ 42 | public static boolean next(Sleeper sleeper, BackOff backOff) 43 | throws InterruptedException, IOException { 44 | long backOffTime = backOff.nextBackOffMillis(); 45 | if (backOffTime == BackOff.STOP) { 46 | return false; 47 | } 48 | sleeper.sleep(backOffTime); 49 | return true; 50 | } 51 | 52 | private BackOffUtils() {} 53 | } 54 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/util/ByteCountingOutputStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.util; 16 | 17 | import java.io.IOException; 18 | import java.io.OutputStream; 19 | 20 | /** 21 | * Output stream that throws away any content and only retains the count of bytes written to the 22 | * stream. 23 | * 24 | * @author Yaniv Inbar 25 | */ 26 | final class ByteCountingOutputStream extends OutputStream { 27 | 28 | /** Number of bytes written. */ 29 | long count; 30 | 31 | @Override 32 | public void write(byte[] b, int off, int len) throws IOException { 33 | count += len; 34 | } 35 | 36 | @Override 37 | public void write(int b) throws IOException { 38 | count++; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/util/Charsets.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.util; 16 | 17 | import java.nio.charset.Charset; 18 | import java.nio.charset.StandardCharsets; 19 | 20 | /** 21 | * Contains constant definitions for some standard {@link Charset} instances that are guaranteed to 22 | * be supported by all Java platform implementations. 23 | * 24 | *

NOTE: this is a copy of a subset of Guava's {@link com.google.common.base.Charsets}. The 25 | * implementation must match as closely as possible to Guava's implementation. 26 | * 27 | * @since 1.14 28 | * @author Yaniv Inbar 29 | * @deprecated use java.nio.charset.StandardCharsets 30 | */ 31 | @Deprecated 32 | public final class Charsets { 33 | 34 | /** UTF-8 charset. */ 35 | public static final Charset UTF_8 = StandardCharsets.UTF_8; 36 | 37 | /** ISO-8859-1 charset. */ 38 | public static final Charset ISO_8859_1 = StandardCharsets.ISO_8859_1; 39 | 40 | private Charsets() {} 41 | } 42 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/util/Clock.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.util; 16 | 17 | /** 18 | * Clock which can be used to get the amount of elapsed milliseconds in system time. 19 | * 20 | *

The default system implementation can be accessed at {@link #SYSTEM}. Alternative 21 | * implementations may be used for testing. 22 | * 23 | * @since 1.9 24 | * @author mlinder@google.com (Matthias Linder) 25 | */ 26 | public interface Clock { 27 | /** 28 | * Returns the current time in milliseconds since midnight, January 1, 1970 UTC, to match the 29 | * behavior of {@link System#currentTimeMillis()}. 30 | */ 31 | long currentTimeMillis(); 32 | 33 | /** 34 | * Provides the default System implementation of a Clock by using {@link 35 | * System#currentTimeMillis()}. 36 | */ 37 | Clock SYSTEM = 38 | new Clock() { 39 | public long currentTimeMillis() { 40 | return System.currentTimeMillis(); 41 | } 42 | }; 43 | } 44 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/util/Collections2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.util; 16 | 17 | import java.util.Collection; 18 | 19 | /** 20 | * Static utility methods pertaining to {@link Collection} instances. 21 | * 22 | * @since 1.14 23 | * @author Yaniv Inbar 24 | * @deprecated use Guava's {@link com.google.common.collect.Collections2} 25 | */ 26 | @Deprecated 27 | public final class Collections2 { 28 | 29 | /** Used to avoid http://bugs.sun.com/view_bug.do?bug_id=6558557. */ 30 | static Collection cast(Iterable iterable) { 31 | return (Collection) iterable; 32 | } 33 | 34 | private Collections2() {} 35 | } 36 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/util/Joiner.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.util; 16 | 17 | import java.util.Map; 18 | 19 | /** 20 | * An object which joins pieces of text (specified as an array, {@link Iterable}, varargs or even a 21 | * {@link Map}) with a separator. 22 | * 23 | *

NOTE: proxy for the Guava implementation of {@link com.google.common.base.Joiner}. 24 | * 25 | * @since 1.14 26 | * @author Yaniv Inbar 27 | */ 28 | public final class Joiner { 29 | 30 | /** Wrapped joiner. */ 31 | private final com.google.common.base.Joiner wrapped; 32 | 33 | /** Returns a joiner which automatically places {@code separator} between consecutive elements. */ 34 | public static Joiner on(char separator) { 35 | return new Joiner(com.google.common.base.Joiner.on(separator)); 36 | } 37 | 38 | /** @param wrapped wrapped joiner */ 39 | private Joiner(com.google.common.base.Joiner wrapped) { 40 | this.wrapped = wrapped; 41 | } 42 | 43 | /** 44 | * Returns a string containing the string representation of each of {@code parts}, using the 45 | * previously configured separator between each. 46 | */ 47 | public final String join(Iterable parts) { 48 | return wrapped.join(parts); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/util/Key.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.util; 16 | 17 | import java.lang.annotation.ElementType; 18 | import java.lang.annotation.Retention; 19 | import java.lang.annotation.RetentionPolicy; 20 | import java.lang.annotation.Target; 21 | 22 | /** 23 | * Use this annotation to specify that a field is a data key, optionally providing the data key name 24 | * to use. 25 | * 26 | *

If the data key name is not specified, the default is the Java field's name. For example: 27 | * 28 | *


29 |  * public class A {
30 |  *
31 |  * // uses data key name of "dataKeyNameMatchesFieldName"
32 |  * @Key
33 |  * public String dataKeyNameMatchesFieldName;
34 |  *
35 |  * // uses data key name of "some_other_name"
36 |  * @Key("some_other_name")
37 |  * private String dataKeyNameIsOverridden;
38 |  *
39 |  * // not a data key
40 |  * private String notADataKey;
41 |  * }
42 |  * 
43 | * 44 | * @since 1.0 45 | * @author Yaniv Inbar 46 | */ 47 | @Target(ElementType.FIELD) 48 | @Retention(RetentionPolicy.RUNTIME) 49 | public @interface Key { 50 | 51 | /** 52 | * Override the data key name of the field or {@code "##default"} to use the Java field's name. 53 | */ 54 | String value() default "##default"; 55 | } 56 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/util/Maps.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.util; 16 | 17 | import java.util.HashMap; 18 | import java.util.LinkedHashMap; 19 | import java.util.Map; 20 | import java.util.TreeMap; 21 | 22 | /** 23 | * Static utility methods pertaining to {@link Map} instances. 24 | * 25 | *

NOTE: this is a copy of a subset of Guava's {@link com.google.common.collect.Maps}. The 26 | * implementation must match as closely as possible to Guava's implementation. 27 | * 28 | * @since 1.14 29 | * @author Yaniv Inbar 30 | */ 31 | public final class Maps { 32 | 33 | /** Returns a new mutable, empty {@code HashMap} instance. */ 34 | public static HashMap newHashMap() { 35 | return new HashMap(); 36 | } 37 | 38 | /** Returns a new mutable, empty, insertion-ordered {@code LinkedHashMap} instance. */ 39 | public static LinkedHashMap newLinkedHashMap() { 40 | return new LinkedHashMap(); 41 | } 42 | 43 | /** 44 | * Returns a new mutable, empty {@code TreeMap} instance using the natural ordering of its 45 | * elements. 46 | */ 47 | public static , V> TreeMap newTreeMap() { 48 | return new TreeMap(); 49 | } 50 | 51 | private Maps() {} 52 | } 53 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/util/NanoClock.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.util; 16 | 17 | /** 18 | * Nano clock which can be used to measure elapsed time in nanoseconds. 19 | * 20 | *

The default system implementation can be accessed at {@link #SYSTEM}. Alternative 21 | * implementations may be used for testing. 22 | * 23 | * @since 1.14 24 | * @author Yaniv Inbar 25 | */ 26 | public interface NanoClock { 27 | 28 | /** 29 | * Returns the current value of the most precise available system timer, in nanoseconds for use to 30 | * measure elapsed time, to match the behavior of {@link System#nanoTime()}. 31 | */ 32 | long nanoTime(); 33 | 34 | /** 35 | * Provides the default System implementation of a nano clock by using {@link System#nanoTime()}. 36 | */ 37 | NanoClock SYSTEM = 38 | new NanoClock() { 39 | public long nanoTime() { 40 | return System.nanoTime(); 41 | } 42 | }; 43 | } 44 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/util/NullValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.util; 16 | 17 | import java.lang.annotation.ElementType; 18 | import java.lang.annotation.Retention; 19 | import java.lang.annotation.RetentionPolicy; 20 | import java.lang.annotation.Target; 21 | 22 | /** 23 | * Use this annotation to specify that an enum constant is the "null" data value to use for {@link 24 | * Data#nullOf(Class)}. 25 | * 26 | *

See {@link Value} for an example. 27 | * 28 | * @since 1.4 29 | * @author Yaniv Inbar 30 | */ 31 | @Target(ElementType.FIELD) 32 | @Retention(RetentionPolicy.RUNTIME) 33 | public @interface NullValue {} 34 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/util/Sets.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.util; 16 | 17 | import java.util.HashSet; 18 | import java.util.Set; 19 | import java.util.TreeSet; 20 | 21 | /** 22 | * Static utility methods pertaining to {@link Set} instances. 23 | * 24 | *

NOTE: this is a copy of a subset of Guava's {@link com.google.common.collect.Sets}. The 25 | * implementation must match as closely as possible to Guava's implementation. 26 | * 27 | * @since 1.14 28 | * @author Yaniv Inbar 29 | */ 30 | public final class Sets { 31 | 32 | /** Returns a new mutable, empty {@code HashSet} instance. */ 33 | public static HashSet newHashSet() { 34 | return new HashSet(); 35 | } 36 | 37 | /** 38 | * Returns a new mutable, empty {@code TreeSet} instance sorted by the natural sort ordering of 39 | * its elements. 40 | */ 41 | public static > TreeSet newTreeSet() { 42 | return new TreeSet(); 43 | } 44 | 45 | private Sets() {} 46 | } 47 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/util/Sleeper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.util; 16 | 17 | /** 18 | * Sleeper interface to use for requesting the current thread to sleep as specified in {@link 19 | * Thread#sleep(long)}. 20 | * 21 | *

The default implementation can be accessed at {@link #DEFAULT}. Primarily used for testing. 22 | * 23 | * @since 1.14 24 | * @author Yaniv Inbar 25 | */ 26 | public interface Sleeper { 27 | 28 | /** 29 | * Causes the currently executing thread to sleep (temporarily cease execution) for the specified 30 | * number of milliseconds as specified in {@link Thread#sleep(long)}. 31 | * 32 | * @param millis length of time to sleep in milliseconds 33 | * @throws InterruptedException if any thread has interrupted the current thread 34 | */ 35 | void sleep(long millis) throws InterruptedException; 36 | 37 | /** Provides the default implementation based on {@link Thread#sleep(long)}. */ 38 | Sleeper DEFAULT = 39 | new Sleeper() { 40 | 41 | public void sleep(long millis) throws InterruptedException { 42 | Thread.sleep(millis); 43 | } 44 | }; 45 | } 46 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/util/StreamingContent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.util; 16 | 17 | import java.io.IOException; 18 | import java.io.OutputStream; 19 | 20 | /** 21 | * Streaming content interface to write bytes to an output stream. 22 | * 23 | *

Implementations don't need to be thread-safe. 24 | * 25 | * @since 1.14 26 | * @author Yaniv Inbar 27 | * @deprecated use com.google.common.io.ByteSink 28 | */ 29 | @Deprecated 30 | public interface StreamingContent { 31 | 32 | /** 33 | * Writes the byte content to the given output stream. 34 | * 35 | *

Implementations must not close the output stream, and instead should flush the output 36 | * stream. Some callers may assume that the output stream has not been closed, and will fail to 37 | * work if it has been closed. 38 | * 39 | * @param out output stream 40 | */ 41 | void writeTo(OutputStream out) throws IOException; 42 | } 43 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/util/Strings.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.util; 16 | 17 | /** 18 | * Static utility methods pertaining to {@code String} instances. 19 | * 20 | *

NOTE: proxy for the Guava implementation of {@link com.google.common.base.Strings}. 21 | * 22 | * @since 1.14 23 | * @author Yaniv Inbar 24 | */ 25 | public final class Strings { 26 | 27 | /** 28 | * Returns {@code true} if the given string is null or is the empty string. 29 | * 30 | * @param string a string reference to check (may be {@code null}) 31 | * @return {@code true} if the string is null or is the empty string 32 | */ 33 | public static boolean isNullOrEmpty(String string) { 34 | return com.google.common.base.Strings.isNullOrEmpty(string); 35 | } 36 | 37 | private Strings() {} 38 | } 39 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/util/Value.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.util; 16 | 17 | import java.lang.annotation.ElementType; 18 | import java.lang.annotation.Retention; 19 | import java.lang.annotation.RetentionPolicy; 20 | import java.lang.annotation.Target; 21 | 22 | /** 23 | * Use this annotation to specify that an enum constant is a string data value, optionally providing 24 | * the string data value to use. 25 | * 26 | *

If the string data value is not specified, the default is the Java field's name. For example: 27 | * 28 | *

29 |  * public enum A {
30 |  *
31 |  * // value is "USE_FIELD_NAME"
32 |  * @Value
33 |  * USE_FIELD_NAME,
34 |  *
35 |  * // value is "specifiedValue"
36 |  * @Value("specifiedValue")
37 |  * USE_SPECIFIED_VALUE,
38 |  *
39 |  * // value is null
40 |  * @NullValue
41 |  * NULL_VALUE
42 |  *
43 |  * // not a value
44 |  * NOT_A_VALUE
45 |  * }
46 |  * 
47 | * 48 | * @since 1.4 49 | * @author Yaniv Inbar 50 | */ 51 | @Target(ElementType.FIELD) 52 | @Retention(RetentionPolicy.RUNTIME) 53 | public @interface Value { 54 | 55 | /** 56 | * Override the string data value of the field or {@code "##default"} to use the Java field's 57 | * name. 58 | */ 59 | String value() default "##default"; 60 | } 61 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/util/escape/Platform.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.util.escape; 16 | 17 | /** Methods factored out so that they can be emulated differently in GWT. */ 18 | final class Platform { 19 | private Platform() {} 20 | 21 | /** Returns a thread-local 1024-char array. */ 22 | // DEST_TL.get() is not null because initialValue() below returns a non-null. 23 | @SuppressWarnings("nullness") 24 | static char[] charBufferFromThreadLocal() { 25 | return DEST_TL.get(); 26 | } 27 | 28 | /** 29 | * A thread-local destination buffer to keep us from creating new buffers. The starting size is 30 | * 1024 characters. If we grow past this we don't put it back in the threadlocal, we just keep 31 | * going and grow as needed. 32 | */ 33 | private static final ThreadLocal DEST_TL = 34 | new ThreadLocal() { 35 | @Override 36 | protected char[] initialValue() { 37 | return new char[1024]; 38 | } 39 | }; 40 | } 41 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/util/escape/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * Character escaping utilities. 17 | * 18 | * @since 1.0 19 | * @author Yaniv Inbar 20 | */ 21 | package com.google.api.client.util.escape; 22 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/util/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * General utilities used throughout this library. 17 | * 18 | * @since 1.0 19 | * @author Yaniv Inbar 20 | */ 21 | @ReflectionSupport(value = ReflectionSupport.Level.FULL) 22 | package com.google.api.client.util; 23 | 24 | import com.google.j2objc.annotations.ReflectionSupport; 25 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/util/store/DataStoreUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.util.store; 16 | 17 | import java.io.IOException; 18 | 19 | /** 20 | * Utilities for data stores. 21 | * 22 | * @author Yaniv Inbar 23 | * @since 1.16 24 | */ 25 | public final class DataStoreUtils { 26 | 27 | /** 28 | * Returns a debug string for the given data store to be used as an implementation of {@link 29 | * Object#toString()}. 30 | * 31 | *

Implementation iterates over {@link DataStore#keySet()}, calling {@link 32 | * DataStore#get(String)} on each key. 33 | * 34 | * @param dataStore data store 35 | * @return debug string 36 | */ 37 | public static String toString(DataStore dataStore) { 38 | try { 39 | StringBuilder sb = new StringBuilder(); 40 | sb.append('{'); 41 | boolean first = true; 42 | for (String key : dataStore.keySet()) { 43 | if (first) { 44 | first = false; 45 | } else { 46 | sb.append(", "); 47 | } 48 | sb.append(key).append('=').append(dataStore.get(key)); 49 | } 50 | return sb.append('}').toString(); 51 | } catch (IOException e) { 52 | throw new RuntimeException(e); 53 | } 54 | } 55 | 56 | private DataStoreUtils() {} 57 | } 58 | -------------------------------------------------------------------------------- /google-http-client/src/main/java/com/google/api/client/util/store/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | /** 16 | * Utilities to store serializable data. 17 | * 18 | * @since 1.16 19 | * @author Yaniv Inbar 20 | */ 21 | package com.google.api.client.util.store; 22 | -------------------------------------------------------------------------------- /google-http-client/src/main/resources/META-INF/native-image/com.google.http-client/google-http-client/native-image.properties: -------------------------------------------------------------------------------- 1 | Args=--enable-url-protocols=http,https -------------------------------------------------------------------------------- /google-http-client/src/main/resources/META-INF/native-image/com.google.http-client/google-http-client/resource-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "resources":[ 3 | {"pattern":"\\Qcom/google/api/client/http/google-http-client.properties\\E"}], 4 | "bundles":[] 5 | } -------------------------------------------------------------------------------- /google-http-client/src/main/resources/META-INF/native-image/com.google.http-client/google-http-client/serialization-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "types":[ 3 | {"name": "com.google.api.client.http.HttpResponseException"}, 4 | {"name": "java.lang.StackTraceElement"}, 5 | {"name":"java.lang.String"}, 6 | {"name": "java.lang.Throwable"}, 7 | {"name": "java.lang.Exception"}, 8 | {"name": "java.io.IOException"}, 9 | {"name": "java.lang.Object"}, 10 | {"name": "java.util.Collections$EmptyList"} 11 | ], 12 | "lambdaCapturingTypes":[ 13 | ], 14 | "proxies":[ 15 | ] 16 | } -------------------------------------------------------------------------------- /google-http-client/src/main/resources/com/google/api/client/http/google-http-client.properties: -------------------------------------------------------------------------------- 1 | google-http-client.version=${project.version} -------------------------------------------------------------------------------- /google-http-client/src/test/java/com/google/api/client/http/BasicAuthenticationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.http; 16 | 17 | import static org.junit.Assert.assertEquals; 18 | 19 | import com.google.api.client.testing.http.HttpTesting; 20 | import com.google.api.client.testing.http.MockHttpTransport; 21 | import org.junit.Test; 22 | import org.junit.runner.RunWith; 23 | import org.junit.runners.JUnit4; 24 | 25 | /** 26 | * Tests {@link BasicAuthentication}. 27 | * 28 | * @author Yaniv Inbar 29 | */ 30 | @RunWith(JUnit4.class) 31 | public class BasicAuthenticationTest { 32 | 33 | static final String USERNAME = "Aladdin"; 34 | 35 | static final String PASSWORD = "open sesame"; 36 | 37 | static final String AUTH_HEADER = "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=="; 38 | 39 | @Test 40 | public void testConstructor() { 41 | BasicAuthentication auth = new BasicAuthentication(USERNAME, PASSWORD); 42 | assertEquals(USERNAME, auth.getUsername()); 43 | assertEquals(PASSWORD, auth.getPassword()); 44 | } 45 | 46 | @Test 47 | public void testInitialize() throws Exception { 48 | BasicAuthentication auth = new BasicAuthentication(USERNAME, PASSWORD); 49 | HttpRequest request = 50 | new MockHttpTransport() 51 | .createRequestFactory() 52 | .buildGetRequest(HttpTesting.SIMPLE_GENERIC_URL); 53 | auth.intercept(request); 54 | assertEquals(AUTH_HEADER, request.getHeaders().getAuthorization()); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /google-http-client/src/test/java/com/google/api/client/http/EmptyContentTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.http; 16 | 17 | import static org.junit.Assert.assertEquals; 18 | import static org.junit.Assert.assertNull; 19 | import static org.junit.Assert.assertTrue; 20 | 21 | import java.io.ByteArrayOutputStream; 22 | import java.io.IOException; 23 | import org.junit.Test; 24 | import org.junit.runner.RunWith; 25 | import org.junit.runners.JUnit4; 26 | 27 | /** 28 | * Tests {@link EmptyContent}. 29 | * 30 | * @author Yaniv Inbar 31 | */ 32 | @RunWith(JUnit4.class) 33 | public class EmptyContentTest { 34 | 35 | @Test 36 | public void test() throws IOException { 37 | EmptyContent content = new EmptyContent(); 38 | assertEquals(0L, content.getLength()); 39 | assertNull(content.getType()); 40 | assertTrue(content.retrySupported()); 41 | ByteArrayOutputStream out = new ByteArrayOutputStream(); 42 | content.writeTo(out); 43 | assertEquals(0, out.size()); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /google-http-client/src/test/java/com/google/api/client/http/HttpRequestFactoryTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.http; 16 | 17 | import static org.junit.Assert.assertEquals; 18 | 19 | import com.google.api.client.http.javanet.NetHttpTransport; 20 | import java.io.IOException; 21 | import org.junit.Test; 22 | import org.junit.runner.RunWith; 23 | import org.junit.runners.JUnit4; 24 | 25 | /** Tests {@link HttpRequestFactory}. */ 26 | @RunWith(JUnit4.class) 27 | public class HttpRequestFactoryTest { 28 | 29 | @Test 30 | public void testBuildRequest_urlShouldBeSet() throws IllegalArgumentException, IOException { 31 | HttpRequestFactory requestFactory = 32 | new NetHttpTransport() 33 | .createRequestFactory( 34 | new HttpRequestInitializer() { 35 | @Override 36 | public void initialize(HttpRequest request) { 37 | // Url should be set by buildRequest method before calling initialize. 38 | if (request.getUrl() == null) { 39 | throw new IllegalArgumentException("url is not set in request"); 40 | } 41 | } 42 | }); 43 | GenericUrl url = new GenericUrl("https://foo.googleapis.com/"); 44 | HttpRequest request = requestFactory.buildRequest("GET", url, null); 45 | assertEquals(url, request.getUrl()); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /google-http-client/src/test/java/com/google/api/client/http/HttpStatusCodesTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.http; 16 | 17 | import static org.junit.Assert.assertFalse; 18 | import static org.junit.Assert.assertTrue; 19 | 20 | import org.junit.Test; 21 | import org.junit.runner.RunWith; 22 | import org.junit.runners.JUnit4; 23 | 24 | /** Tests {@link HttpStatusCodes}. */ 25 | @RunWith(JUnit4.class) 26 | public class HttpStatusCodesTest { 27 | 28 | @Test 29 | public void testIsRedirect_3xx() { 30 | assertTrue(HttpStatusCodes.isRedirect(301)); 31 | assertTrue(HttpStatusCodes.isRedirect(302)); 32 | assertTrue(HttpStatusCodes.isRedirect(303)); 33 | assertTrue(HttpStatusCodes.isRedirect(307)); 34 | assertTrue(HttpStatusCodes.isRedirect(308)); 35 | } 36 | 37 | @Test 38 | public void testIsRedirect_non3xx() { 39 | assertFalse(HttpStatusCodes.isRedirect(200)); 40 | assertFalse(HttpStatusCodes.isRedirect(401)); 41 | assertFalse(HttpStatusCodes.isRedirect(500)); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /google-http-client/src/test/java/com/google/api/client/json/GenericJsonTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.json; 16 | 17 | import static org.junit.Assert.assertEquals; 18 | 19 | import org.junit.Test; 20 | import org.junit.runner.RunWith; 21 | import org.junit.runners.JUnit4; 22 | 23 | /** 24 | * Tests {@link GenericJson}. 25 | * 26 | * @author Yaniv Inbar 27 | */ 28 | @RunWith(JUnit4.class) 29 | public class GenericJsonTest { 30 | 31 | @Test 32 | public void testToString_noFactory() { 33 | GenericJson data = new GenericJson(); 34 | data.put("a", "b"); 35 | assertEquals("GenericData{classInfo=[], {a=b}}", data.toString()); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /google-http-client/src/test/java/com/google/api/client/json/JsonParserTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.json; 16 | 17 | import static org.junit.Assert.assertEquals; 18 | import static org.junit.Assert.assertTrue; 19 | 20 | import com.google.api.client.testing.json.MockJsonFactory; 21 | import com.google.api.client.testing.json.MockJsonParser; 22 | import org.junit.Test; 23 | import org.junit.runner.RunWith; 24 | import org.junit.runners.JUnit4; 25 | 26 | /** 27 | * Tests {@link JsonParser}. 28 | * 29 | * @author Yaniv Inbar 30 | */ 31 | @RunWith(JUnit4.class) 32 | public class JsonParserTest { 33 | 34 | @Test 35 | public void testParseAndClose_noInput() throws Exception { 36 | MockJsonParser parser = (MockJsonParser) new MockJsonFactory().createJsonParser(""); 37 | try { 38 | parser.parseAndClose(Object.class); 39 | } catch (IllegalArgumentException e) { 40 | assertEquals("no JSON input found", e.getMessage()); 41 | assertTrue(parser.isClosed()); 42 | } 43 | } 44 | 45 | @Test 46 | public void testParseAndClose_noInputVoid() throws Exception { 47 | MockJsonParser parser = (MockJsonParser) new MockJsonFactory().createJsonParser(""); 48 | parser.parseAndClose(Void.class); 49 | assertTrue(parser.isClosed()); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /google-http-client/src/test/java/com/google/api/client/testing/http/FixedClockTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.testing.http; 16 | 17 | import static org.junit.Assert.assertEquals; 18 | 19 | import org.junit.Test; 20 | import org.junit.runner.RunWith; 21 | import org.junit.runners.JUnit4; 22 | 23 | /** 24 | * Tests for the {@link FixedClock}. 25 | * 26 | * @author mlinder@google.com (Matthias Linder) 27 | */ 28 | @RunWith(JUnit4.class) 29 | public class FixedClockTest { 30 | /** Tests that the {@link FixedClock#currentTimeMillis()} method will return the mocked values. */ 31 | @Test 32 | public void testCurrentTimeMillis() { 33 | // Check that the initial value is set properly. 34 | FixedClock clock = new FixedClock(100); 35 | assertEquals(100, clock.currentTimeMillis()); 36 | 37 | // Check that the clock returns the new value once set. 38 | clock.setTime(500); 39 | assertEquals(500, clock.currentTimeMillis()); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /google-http-client/src/test/java/com/google/api/client/testing/http/MockLowLevelHttpRequestTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.testing.http; 16 | 17 | import static org.junit.Assert.assertEquals; 18 | 19 | import com.google.api.client.util.ByteArrayStreamingContent; 20 | import com.google.api.client.util.StringUtils; 21 | import org.junit.Test; 22 | import org.junit.runner.RunWith; 23 | import org.junit.runners.JUnit4; 24 | 25 | /** 26 | * Tests {@link MockLowLevelHttpRequest}. 27 | * 28 | * @author Yaniv Inbar 29 | */ 30 | @RunWith(JUnit4.class) 31 | public class MockLowLevelHttpRequestTest { 32 | 33 | @Test 34 | public void testGetContentAsString() throws Exception { 35 | subtestGetContentAsString("", null); 36 | subtestGetContentAsString("hello", "hello"); 37 | } 38 | 39 | public void subtestGetContentAsString(String expected, String content) throws Exception { 40 | MockLowLevelHttpRequest request = new MockLowLevelHttpRequest(); 41 | if (content != null) { 42 | byte[] bytes = StringUtils.getBytesUtf8(content); 43 | request.setStreamingContent(new ByteArrayStreamingContent(bytes)); 44 | } 45 | assertEquals(expected, request.getContentAsString()); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /google-http-client/src/test/java/com/google/api/client/testing/util/MockBackOffTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.testing.util; 16 | 17 | import static org.junit.Assert.assertEquals; 18 | 19 | import com.google.api.client.util.BackOff; 20 | import java.io.IOException; 21 | import org.junit.Test; 22 | import org.junit.runner.RunWith; 23 | import org.junit.runners.JUnit4; 24 | 25 | /** 26 | * Tests {@link MockBackOff}. 27 | * 28 | * @author Yaniv Inbar 29 | */ 30 | @RunWith(JUnit4.class) 31 | public class MockBackOffTest { 32 | 33 | @Test 34 | public void testNextBackOffMillis() throws IOException { 35 | subtestNextBackOffMillis(0, new MockBackOff()); 36 | subtestNextBackOffMillis(BackOff.STOP, new MockBackOff().setBackOffMillis(BackOff.STOP)); 37 | subtestNextBackOffMillis(42, new MockBackOff().setBackOffMillis(42)); 38 | } 39 | 40 | public void subtestNextBackOffMillis(long expectedValue, BackOff backOffPolicy) 41 | throws IOException { 42 | for (int i = 0; i < 10; i++) { 43 | assertEquals(expectedValue, backOffPolicy.nextBackOffMillis()); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /google-http-client/src/test/java/com/google/api/client/util/BackOffTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.util; 16 | 17 | import static org.junit.Assert.assertEquals; 18 | 19 | import java.io.IOException; 20 | import org.junit.Test; 21 | import org.junit.runner.RunWith; 22 | import org.junit.runners.JUnit4; 23 | 24 | /** 25 | * Tests {@link BackOff}. 26 | * 27 | * @author Yaniv Inbar 28 | */ 29 | @RunWith(JUnit4.class) 30 | public class BackOffTest { 31 | 32 | @Test 33 | public void testNextBackOffMillis() throws IOException { 34 | subtestNextBackOffMillis(0, BackOff.ZERO_BACKOFF); 35 | subtestNextBackOffMillis(BackOff.STOP, BackOff.STOP_BACKOFF); 36 | } 37 | 38 | public void subtestNextBackOffMillis(long expectedValue, BackOff backOffPolicy) 39 | throws IOException { 40 | for (int i = 0; i < 10; i++) { 41 | assertEquals(expectedValue, backOffPolicy.nextBackOffMillis()); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /google-http-client/src/test/java/com/google/api/client/util/ClockTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.util; 16 | 17 | import static org.junit.Assert.assertNotNull; 18 | import static org.junit.Assert.assertTrue; 19 | 20 | import org.junit.Test; 21 | import org.junit.runner.RunWith; 22 | import org.junit.runners.JUnit4; 23 | 24 | /** 25 | * Tests for the {@link Clock}. 26 | * 27 | * @author mlinder@google.com (Matthias Linder) 28 | */ 29 | @RunWith(JUnit4.class) 30 | public class ClockTest { 31 | /** Tests that the Clock.SYSTEM.currentTimeMillis() method returns useful values. */ 32 | @Test 33 | public void testSystemClock() { 34 | assertNotNull(Clock.SYSTEM); 35 | 36 | // Confirm that the value returned here is similar to the system value. 37 | final long ERROR_MARGIN = 1000; 38 | long systemValue = System.currentTimeMillis(); 39 | long clockValue = Clock.SYSTEM.currentTimeMillis(); 40 | assertTrue(Math.abs(clockValue - systemValue) <= ERROR_MARGIN); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /google-http-client/src/test/java/com/google/api/client/util/NanoClockTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.util; 16 | 17 | import static org.junit.Assert.assertNotNull; 18 | import static org.junit.Assert.assertTrue; 19 | 20 | import org.junit.Test; 21 | import org.junit.runner.RunWith; 22 | import org.junit.runners.JUnit4; 23 | 24 | /** 25 | * Tests {@link NanoClock}. 26 | * 27 | * @author Yaniv Inbar 28 | */ 29 | @RunWith(JUnit4.class) 30 | public class NanoClockTest { 31 | 32 | @Test 33 | public void testSystemClock() { 34 | assertNotNull(NanoClock.SYSTEM); 35 | 36 | // Confirm that the value returned here is similar to the system value. 37 | final long ERROR_MARGIN = 1000000000; 38 | long systemValue = System.nanoTime(); 39 | long clockValue = NanoClock.SYSTEM.nanoTime(); 40 | assertTrue( 41 | clockValue + " != " + systemValue, Math.abs(clockValue - systemValue) <= ERROR_MARGIN); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /google-http-client/src/test/java/com/google/api/client/util/ObjectsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.util; 16 | 17 | import static org.junit.Assert.assertEquals; 18 | 19 | import org.junit.Test; 20 | import org.junit.runner.RunWith; 21 | import org.junit.runners.JUnit4; 22 | 23 | /** 24 | * Tests {@link Objects}. 25 | * 26 | * @author Yaniv Inbar 27 | */ 28 | @RunWith(JUnit4.class) 29 | public class ObjectsTest { 30 | @Test 31 | public void testToStringHelper() { 32 | String toTest = Objects.toStringHelper(new TestClass()).add("hello", "world").toString(); 33 | assertEquals("TestClass{hello=world}", toTest); 34 | } 35 | 36 | @Test 37 | public void testConstructor_innerClass() { 38 | String toTest = Objects.toStringHelper(new TestClass()).toString(); 39 | assertEquals("TestClass{}", toTest); 40 | } 41 | 42 | @Test 43 | public void testToString_oneIntegerField() { 44 | String toTest = 45 | Objects.toStringHelper(new TestClass()).add("field1", Integer.valueOf(42)).toString(); 46 | assertEquals("TestClass{field1=42}", toTest); 47 | } 48 | 49 | @Test 50 | public void testToStringOmitNullValues_oneField() { 51 | String toTest = 52 | Objects.toStringHelper(new TestClass()).omitNullValues().add("field1", null).toString(); 53 | assertEquals("TestClass{}", toTest); 54 | } 55 | 56 | private static class TestClass {} 57 | } 58 | -------------------------------------------------------------------------------- /google-http-client/src/test/java/com/google/api/client/util/StringUtilsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.util; 16 | 17 | import static org.junit.Assert.assertEquals; 18 | import static org.junit.Assert.assertNotNull; 19 | import static org.junit.Assert.assertNull; 20 | 21 | import org.junit.Assert; 22 | import org.junit.Test; 23 | import org.junit.runner.RunWith; 24 | import org.junit.runners.JUnit4; 25 | 26 | /** 27 | * Tests {@link StringUtils}. 28 | * 29 | * @author Yaniv Inbar 30 | */ 31 | @RunWith(JUnit4.class) 32 | public class StringUtilsTest { 33 | 34 | private static final byte[] SAMPLE_UTF8 = 35 | new byte[] {49, 50, 51, -41, -103, -41, -96, -41, -103, -41, -111}; 36 | private static final String SAMPLE = "123\u05D9\u05e0\u05D9\u05D1"; 37 | 38 | @Test 39 | public void testLineSeparator() { 40 | assertNotNull(StringUtils.LINE_SEPARATOR); 41 | } 42 | 43 | @Test 44 | public void testToBytesUtf8() { 45 | Assert.assertArrayEquals(SAMPLE_UTF8, StringUtils.getBytesUtf8(SAMPLE)); 46 | } 47 | 48 | @Test 49 | public void testToBytesUtf8Null() { 50 | assertNull(StringUtils.getBytesUtf8(null)); 51 | } 52 | 53 | @Test 54 | public void testFromBytesUtf8() { 55 | assertEquals(SAMPLE, StringUtils.newStringUtf8(SAMPLE_UTF8)); 56 | } 57 | 58 | @Test 59 | public void testFromBytesUtf8Null() { 60 | assertNull(StringUtils.newStringUtf8(null)); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /google-http-client/src/test/java/com/google/api/client/util/escape/PercentEscaperTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.api.client.util.escape; 16 | 17 | import org.junit.Assert; 18 | import org.junit.Test; 19 | import org.junit.runner.RunWith; 20 | import org.junit.runners.JUnit4; 21 | 22 | @RunWith(JUnit4.class) 23 | public class PercentEscaperTest { 24 | 25 | @Test 26 | public void testEscapeSpace() { 27 | PercentEscaper escaper = 28 | new PercentEscaper(PercentEscaper.SAFE_PLUS_RESERVED_CHARS_URLENCODER, false); 29 | String actual = escaper.escape("Hello there"); 30 | Assert.assertEquals("Hello%20there", actual); 31 | } 32 | 33 | @Test 34 | public void testEscapeSpaceDefault() { 35 | PercentEscaper escaper = new PercentEscaper(PercentEscaper.SAFE_PLUS_RESERVED_CHARS_URLENCODER); 36 | String actual = escaper.escape("Hello there"); 37 | Assert.assertEquals("Hello%20there", actual); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /google-http-client/src/test/resources/META-INF/native-image/com.google.http-client/google-http-client/native-image.properties: -------------------------------------------------------------------------------- 1 | Args=--initialize-at-build-time=com.google.api.client.util.StringUtils \ 2 | --initialize-at-build-time=com.google.common.collect.RegularImmutableSet \ 3 | --initialize-at-build-time=org.junit.runner.RunWith \ 4 | --initialize-at-build-time=org.junit.runners.model.FrameworkField \ -------------------------------------------------------------------------------- /google-http-client/src/test/resources/META-INF/native-image/com.google.http-client/google-http-client/resource-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "resources":[ 3 | {"pattern":"\\Qcom/google/api/client/util/privateKey.pem\\E"}, 4 | {"pattern":"\\Qcom/google/api/client/util/cert.pem\\E"}, 5 | {"pattern":"\\Qcom/google/api/client/util/mtlsCertAndKey.pem\\E"}, 6 | {"pattern": "\\Qfile.txt\\E"}, 7 | {"pattern": "\\Qcom/google/api/client/util/secret.pem\\E"}, 8 | {"pattern": "\\Qcom/google/api/client/util/secret.p12\\E"}], 9 | "bundles":[] 10 | } -------------------------------------------------------------------------------- /google-http-client/src/test/resources/com/google/api/client/util/cert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICGzCCAYSgAwIBAgIIWrt6xtmHPs4wDQYJKoZIhvcNAQEFBQAwMzExMC8GA1UE 3 | AxMoMTAwOTEyMDcyNjg3OC5hcHBzLmdvb2dsZXVzZXJjb250ZW50LmNvbTAeFw0x 4 | MjEyMDExNjEwNDRaFw0yMjExMjkxNjEwNDRaMDMxMTAvBgNVBAMTKDEwMDkxMjA3 5 | MjY4NzguYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20wgZ8wDQYJKoZIhvcNAQEB 6 | BQADgY0AMIGJAoGBAL1SdY8jTUVU7O4/XrZLYTw0ON1lV6MQRGajFDFCqD2Fd9tQ 7 | GLW8Iftx9wfXe1zuaehJSgLcyCxazfyJoN3RiONBihBqWY6d3lQKqkgsRTNZkdFJ 8 | Wdzl/6CxhK9sojh2p0r3tydtv9iwq5fuuWIvtODtT98EgphhncQAqkKoF3zVAgMB 9 | AAGjODA2MAwGA1UdEwEB/wQCMAAwDgYDVR0PAQH/BAQDAgeAMBYGA1UdJQEB/wQM 10 | MAoGCCsGAQUFBwMCMA0GCSqGSIb3DQEBBQUAA4GBAD8XQEqzGePa9VrvtEGpf+R4 11 | fkxKbcYAzqYq202nKu0kfjhIYkYSBj6gi348YaxE64yu60TVl42l5HThmswUheW4 12 | uQIaq36JvwvsDP5Zoj5BgiNSnDAFQp+jJFBRUA5vooJKgKgMDf/r/DCOsbO6VJF1 13 | kWwa9n19NFiV0z3m6isj 14 | -----END CERTIFICATE----- -------------------------------------------------------------------------------- /google-http-client/src/test/resources/com/google/api/client/util/mtlsCertAndKey.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICGzCCAYSgAwIBAgIIWrt6xtmHPs4wDQYJKoZIhvcNAQEFBQAwMzExMC8GA1UE 3 | AxMoMTAwOTEyMDcyNjg3OC5hcHBzLmdvb2dsZXVzZXJjb250ZW50LmNvbTAeFw0x 4 | MjEyMDExNjEwNDRaFw0yMjExMjkxNjEwNDRaMDMxMTAvBgNVBAMTKDEwMDkxMjA3 5 | MjY4NzguYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20wgZ8wDQYJKoZIhvcNAQEB 6 | BQADgY0AMIGJAoGBAL1SdY8jTUVU7O4/XrZLYTw0ON1lV6MQRGajFDFCqD2Fd9tQ 7 | GLW8Iftx9wfXe1zuaehJSgLcyCxazfyJoN3RiONBihBqWY6d3lQKqkgsRTNZkdFJ 8 | Wdzl/6CxhK9sojh2p0r3tydtv9iwq5fuuWIvtODtT98EgphhncQAqkKoF3zVAgMB 9 | AAGjODA2MAwGA1UdEwEB/wQCMAAwDgYDVR0PAQH/BAQDAgeAMBYGA1UdJQEB/wQM 10 | MAoGCCsGAQUFBwMCMA0GCSqGSIb3DQEBBQUAA4GBAD8XQEqzGePa9VrvtEGpf+R4 11 | fkxKbcYAzqYq202nKu0kfjhIYkYSBj6gi348YaxE64yu60TVl42l5HThmswUheW4 12 | uQIaq36JvwvsDP5Zoj5BgiNSnDAFQp+jJFBRUA5vooJKgKgMDf/r/DCOsbO6VJF1 13 | kWwa9n19NFiV0z3m6isj 14 | -----END CERTIFICATE----- 15 | -----BEGIN PRIVATE KEY----- 16 | MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAL1SdY8jTUVU7O4/ 17 | XrZLYTw0ON1lV6MQRGajFDFCqD2Fd9tQGLW8Iftx9wfXe1zuaehJSgLcyCxazfyJ 18 | oN3RiONBihBqWY6d3lQKqkgsRTNZkdFJWdzl/6CxhK9sojh2p0r3tydtv9iwq5fu 19 | uWIvtODtT98EgphhncQAqkKoF3zVAgMBAAECgYB51B9cXe4yiGTzJ4pOKpHGySAy 20 | sC1F/IjXt2eeD3PuKv4m/hL4l7kScpLx0+NJuQ4j8U2UK/kQOdrGANapB1ZbMZAK 21 | /q0xmIUzdNIDiGSoTXGN2mEfdsEpQ/Xiv0lyhYBBPC/K4sYIpHccnhSRQUZlWLLY 22 | lE5cFNKC9b7226mNvQJBAPt0hfCNIN0kUYOA9jdLtx7CE4ySGMPf5KPBuzPd8ty1 23 | fxaFm9PB7B76VZQYmHcWy8rT5XjoLJHrmGW1ZvP+iDsCQQDAvnKoarPOGb5iJfkq 24 | RrA4flf1TOlf+1+uqIOJ94959jkkJeb0gv/TshDnm6/bWn+1kJylQaKygCizwPwB 25 | Z84vAkA0Duur4YvsPJijoQ9YY1SGCagCcjyuUKwFOxaGpmyhRPIKt56LOJqpzyno 26 | fy8ReKa4VyYq4eZYT249oFCwMwIBAkAROPNF2UL3x5UbcAkznd1hLujtIlI4IV4L 27 | XUNjsJtBap7we/KHJq11XRPlniO4lf2TW7iji5neGVWJulTKS1xBAkAerktk4Hsw 28 | ErUaUG1s/d+Sgc8e/KMeBElV+NxGhcWEeZtfHMn/6VOlbzY82JyvC9OKC80A5CAE 29 | VUV6b25kqrcu 30 | -----END PRIVATE KEY----- -------------------------------------------------------------------------------- /google-http-client/src/test/resources/com/google/api/client/util/privateKey.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAL1SdY8jTUVU7O4/ 3 | XrZLYTw0ON1lV6MQRGajFDFCqD2Fd9tQGLW8Iftx9wfXe1zuaehJSgLcyCxazfyJ 4 | oN3RiONBihBqWY6d3lQKqkgsRTNZkdFJWdzl/6CxhK9sojh2p0r3tydtv9iwq5fu 5 | uWIvtODtT98EgphhncQAqkKoF3zVAgMBAAECgYB51B9cXe4yiGTzJ4pOKpHGySAy 6 | sC1F/IjXt2eeD3PuKv4m/hL4l7kScpLx0+NJuQ4j8U2UK/kQOdrGANapB1ZbMZAK 7 | /q0xmIUzdNIDiGSoTXGN2mEfdsEpQ/Xiv0lyhYBBPC/K4sYIpHccnhSRQUZlWLLY 8 | lE5cFNKC9b7226mNvQJBAPt0hfCNIN0kUYOA9jdLtx7CE4ySGMPf5KPBuzPd8ty1 9 | fxaFm9PB7B76VZQYmHcWy8rT5XjoLJHrmGW1ZvP+iDsCQQDAvnKoarPOGb5iJfkq 10 | RrA4flf1TOlf+1+uqIOJ94959jkkJeb0gv/TshDnm6/bWn+1kJylQaKygCizwPwB 11 | Z84vAkA0Duur4YvsPJijoQ9YY1SGCagCcjyuUKwFOxaGpmyhRPIKt56LOJqpzyno 12 | fy8ReKa4VyYq4eZYT249oFCwMwIBAkAROPNF2UL3x5UbcAkznd1hLujtIlI4IV4L 13 | XUNjsJtBap7we/KHJq11XRPlniO4lf2TW7iji5neGVWJulTKS1xBAkAerktk4Hsw 14 | ErUaUG1s/d+Sgc8e/KMeBElV+NxGhcWEeZtfHMn/6VOlbzY82JyvC9OKC80A5CAE 15 | VUV6b25kqrcu 16 | -----END PRIVATE KEY----- -------------------------------------------------------------------------------- /google-http-client/src/test/resources/com/google/api/client/util/secret.p12: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleapis/google-http-java-client/0d1726114ca678d8a9c8e3e231e0ab7205eb8395/google-http-client/src/test/resources/com/google/api/client/util/secret.p12 -------------------------------------------------------------------------------- /google-http-client/src/test/resources/file.txt: -------------------------------------------------------------------------------- 1 | some sample file 2 | -------------------------------------------------------------------------------- /instructions.html: -------------------------------------------------------------------------------- 1 | 2 | Setup Instructions for the Google API Client Library for Java 3 | 4 |

Setup Instructions for the Google API Client Library for Java

5 | 6 |

Browse Online

7 | 8 | 13 | 14 |

Checkout Instructions

15 | 16 |

Prerequisites: install 17 | 18 | Java SE 8, 19 | Git and Maven. You may need to set 21 | your JAVA_HOME.

22 | 23 |
git clone https://github.com/googleapis/google-http-java-client.git
24 | cd google-http-java-client
25 | mvn install
26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /samples/dailymotion-simple-cmdline-sample/logging.properties: -------------------------------------------------------------------------------- 1 | # Properties file which configures the operation of the JDK logging facility. 2 | # The system will look for this config file to be specified as a system property: 3 | # -Djava.util.logging.config.file=${project_loc:dailymotion-simple-cmdline-sample}/logging.properties 4 | 5 | # Set up the console handler (uncomment "level" to show more fine-grained messages) 6 | handlers = java.util.logging.ConsoleHandler 7 | #java.util.logging.ConsoleHandler.level = CONFIG 8 | 9 | # Set up logging of HTTP requests and responses (uncomment "level" to show) 10 | #com.google.api.client.http.level = CONFIG 11 | -------------------------------------------------------------------------------- /versions.txt: -------------------------------------------------------------------------------- 1 | # Format: 2 | # module:released-version:current-version 3 | 4 | google-http-client:1.47.0:1.47.1-SNAPSHOT 5 | google-http-client-bom:1.47.0:1.47.1-SNAPSHOT 6 | google-http-client-parent:1.47.0:1.47.1-SNAPSHOT 7 | google-http-client-android:1.47.0:1.47.1-SNAPSHOT 8 | google-http-client-android-test:1.47.0:1.47.1-SNAPSHOT 9 | google-http-client-apache-v2:1.47.0:1.47.1-SNAPSHOT 10 | google-http-client-apache-v5:1.47.0:1.47.1-SNAPSHOT 11 | google-http-client-appengine:1.47.0:1.47.1-SNAPSHOT 12 | google-http-client-assembly:1.47.0:1.47.1-SNAPSHOT 13 | google-http-client-findbugs:1.47.0:1.47.1-SNAPSHOT 14 | google-http-client-gson:1.47.0:1.47.1-SNAPSHOT 15 | google-http-client-jackson2:1.47.0:1.47.1-SNAPSHOT 16 | google-http-client-protobuf:1.47.0:1.47.1-SNAPSHOT 17 | google-http-client-test:1.47.0:1.47.1-SNAPSHOT 18 | google-http-client-xml:1.47.0:1.47.1-SNAPSHOT 19 | --------------------------------------------------------------------------------