You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by on...@apache.org on 2018/07/10 07:02:25 UTC

[camel] branch master updated (f303d87 -> 33166ad)

This is an automated email from the ASF dual-hosted git repository.

onders pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from f303d87  Fixed Camel-Kubernetes after upgrading to client 4.0.0
     new e31c625  CAMEL-12554 - camel-geocoder - Use new API using com.google.maps:google-maps-services instead of com.google.code.geocoder-java:geocoder-java
     new bf61db5  implemented proxy support for GeoCoderEndpoint, removed commons-httpclient
     new 52843c8  introduced google-maps-services-version parameter for the Maps API library
     new 33166ad  CAMEL-12554 - fix cs and component validation error

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 components/camel-geocoder/pom.xml                  |  13 +-
 .../src/main/docs/geocoder-component.adoc          |  15 +-
 .../component/geocoder/GeoCoderConstants.java      |   1 +
 .../camel/component/geocoder/GeoCoderEndpoint.java | 149 ++++--------
 .../camel/component/geocoder/GeoCoderProducer.java | 268 +++++++++++----------
 .../camel/component/geocoder/GeocoderStatus.java}  |  28 ++-
 .../http/AuthenticationHttpClientConfigurer.java   |  54 -----
 .../geocoder/http/AuthenticationMethod.java        |   2 +-
 .../geocoder/http/CompositeHttpConfigurer.java     |  50 ----
 .../geocoder/http/HttpClientConfigurer.java        |  35 ---
 .../geocoder/GeoCoderApiKeyTestBase.java}          |  18 +-
 .../geocoder/GeoCoderComponentAddressTest.java     |  16 +-
 .../geocoder/GeoCoderCurrentAddressTest.java       |   6 +-
 ...ressTest.java => GeoCoderEmptyAddressTest.java} |   8 +-
 .../geocoder/GeoCoderLatLngComponentTest.java      |   5 +-
 .../component/geocoder/GeoCoderProxyTest.java      |  47 ++--
 parent/pom.xml                                     |   2 +-
 17 files changed, 285 insertions(+), 432 deletions(-)
 copy components/{camel-consul/src/main/java/org/apache/camel/component/consul/endpoint/ConsulHealthActions.java => camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeocoderStatus.java} (71%)
 delete mode 100644 components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/http/AuthenticationHttpClientConfigurer.java
 delete mode 100644 components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/http/CompositeHttpConfigurer.java
 delete mode 100644 components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/http/HttpClientConfigurer.java
 copy components/{camel-ganglia/src/test/java/org/apache/camel/component/ganglia/CamelGangliaTestSupport.java => camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderApiKeyTestBase.java} (65%)
 copy components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/{GeoCoderComponentAddressTest.java => GeoCoderEmptyAddressTest.java} (87%)


[camel] 03/04: introduced google-maps-services-version parameter for the Maps API library

Posted by on...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

onders pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 52843c8db0a1969b8f8be6c83f4eb64945101af0
Author: jborza <jb...@gmail.com>
AuthorDate: Sun Jul 8 09:05:42 2018 +0200

    introduced google-maps-services-version parameter for the Maps API library
---
 components/camel-geocoder/pom.xml | 2 +-
 parent/pom.xml                    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/components/camel-geocoder/pom.xml b/components/camel-geocoder/pom.xml
index ed56b89..7a414a3 100644
--- a/components/camel-geocoder/pom.xml
+++ b/components/camel-geocoder/pom.xml
@@ -46,7 +46,7 @@
     <dependency>
       <groupId>com.google.maps</groupId>
       <artifactId>google-maps-services</artifactId>
-      <version>0.2.7</version>
+      <version>${google-maps-services-version}</version>
     </dependency>
     <!-- testing -->
     <dependency>
diff --git a/parent/pom.xml b/parent/pom.xml
index d36e462..97a796b 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -228,6 +228,7 @@
     <findbugs-maven-plugin-version>2.5.2</findbugs-maven-plugin-version>
     <google-findbugs-jsr305-version>3.0.2</google-findbugs-jsr305-version>
     <google-findbugs-annotations2-version>2.0.3</google-findbugs-annotations2-version>
+    <google-maps-services-version>0.2.9</google-maps-services-version>
     <flatpack-version>3.4.3</flatpack-version>
     <flink-version>1.5.0</flink-version>
     <fop-bundle-version>2.3_1</fop-bundle-version>
@@ -236,7 +237,6 @@
     <freemarker-version>2.3.28</freemarker-version>
     <generex-bundle-version>1.0.1_2</generex-bundle-version>
     <gentlyweb-bundle-version>1.5_1</gentlyweb-bundle-version>
-    <geocoder-java-version>0.16</geocoder-java-version>
     <geronimo-annotation-1.0-spec-version>1.1.1</geronimo-annotation-1.0-spec-version>
     <geronimo-annotation-1.2-spec-version>1.0</geronimo-annotation-1.2-spec-version>
     <geronimo-atinject-1.0-spec-version>1.0</geronimo-atinject-1.0-spec-version>


[camel] 04/04: CAMEL-12554 - fix cs and component validation error

Posted by on...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

onders pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 33166ad893be00ee8d785291aeb31c32f5bcdd95
Author: onders <on...@apache.org>
AuthorDate: Mon Jul 9 23:11:47 2018 +0300

    CAMEL-12554 - fix cs and component validation error
---
 .../apache/camel/component/geocoder/GeoCoderEndpoint.java  | 14 ++++++++------
 .../apache/camel/component/geocoder/GeoCoderProxyTest.java | 14 ++++++++------
 2 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderEndpoint.java b/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderEndpoint.java
index c1e4595..ae279da 100644
--- a/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderEndpoint.java
+++ b/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderEndpoint.java
@@ -6,7 +6,7 @@
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
  *
- * http://www.apache.org/licenses/LICENSE-2.0
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,6 +16,9 @@
  */
 package org.apache.camel.component.geocoder;
 
+import java.net.InetSocketAddress;
+import java.net.Proxy;
+
 import com.google.maps.GeoApiContext;
 import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
@@ -26,9 +29,6 @@ import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriPath;
 
-import java.net.InetSocketAddress;
-import java.net.Proxy;
-
 /**
  * The geocoder component is used for looking up geocodes (latitude and longitude) for a given address, or reverse lookup.
  */
@@ -154,6 +154,9 @@ public class GeoCoderEndpoint extends DefaultEndpoint {
         return apiKey;
     }
 
+    /**
+     * To use google apiKey
+     */
     public void setApiKey(String apiKey) {
         this.apiKey = apiKey;
     }
@@ -252,8 +255,7 @@ public class GeoCoderEndpoint extends DefaultEndpoint {
         AuthenticationMethod auth = getCamelContext().getTypeConverter().convertTo(AuthenticationMethod.class, proxyAuthMethod);
         if (auth == AuthenticationMethod.Basic || auth == AuthenticationMethod.Digest) {
             builder = builder.proxyAuthentication(proxyAuthUsername, proxyAuthPassword);
-        }
-        else{
+        } else {
             throw new IllegalArgumentException("Unknown proxyAuthMethod " + proxyAuthMethod);
         }
         return builder;
diff --git a/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderProxyTest.java b/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderProxyTest.java
index 58721f7..0da9cad 100644
--- a/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderProxyTest.java
+++ b/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderProxyTest.java
@@ -31,9 +31,10 @@ public class GeoCoderProxyTest extends GeoCoderApiKeyTestBase {
 
     @Test
     public void testGeoCoderProxyNoAuth() throws Exception {
-        GeoCoderEndpoint endpoint = context.getEndpoint(
-            "geocoder:address:current?headersOnly=true&proxyHost=localhost&proxyPort=8888&apiKey="+getApiKey(),
-            GeoCoderEndpoint.class);
+        GeoCoderEndpoint endpoint = context.
+                getEndpoint("geocoder:address:current?headersOnly=true&proxyHost=localhost"
+                        + "&proxyPort=8888&apiKey=" + getApiKey(),
+                             GeoCoderEndpoint.class);
 
         GeoApiContext context = endpoint.createGeoApiContext();
         GeocodingApiRequest geocodingApiRequest = GeocodingApi.reverseGeocode(context, new LatLng(45.4643, 9.1895));
@@ -44,9 +45,10 @@ public class GeoCoderProxyTest extends GeoCoderApiKeyTestBase {
 
     @Test
     public void testGeoCoderWithAuth() throws Exception {
-        GeoCoderEndpoint endpoint = context.getEndpoint(
-                "geocoder:address:current?headersOnly=true&proxyHost=localhost&proxyPort=8888&proxyAuthMethod=Basic&proxyAuthUsername=proxy&proxyAuthPassword=proxy&apiKey="+getApiKey(),
-                GeoCoderEndpoint.class);
+        GeoCoderEndpoint endpoint = context.
+                getEndpoint("geocoder:address:current?headersOnly=true&proxyHost=localhost"
+                       + "&proxyPort=8888&proxyAuthMethod=Basic&proxyAuthUsername=proxy&proxyAuthPassword=proxy&apiKey=" + getApiKey(),
+                             GeoCoderEndpoint.class);
 
         GeoApiContext context = endpoint.createGeoApiContext();
         GeocodingApiRequest geocodingApiRequest = GeocodingApi.reverseGeocode(context, new LatLng(45.4643, 9.1895));


[camel] 01/04: CAMEL-12554 - camel-geocoder - Use new API using com.google.maps:google-maps-services instead of com.google.code.geocoder-java:geocoder-java

Posted by on...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

onders pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit e31c6251d428edd5e79d1a79dde322ff8b0b5f4b
Author: jborza <jb...@gmail.com>
AuthorDate: Sun Jun 10 18:27:46 2018 +0200

    CAMEL-12554 - camel-geocoder - Use new API
    using com.google.maps:google-maps-services instead of com.google.code.geocoder-java:geocoder-java
---
 components/camel-geocoder/pom.xml                  |  17 +-
 .../src/main/docs/geocoder-component.adoc          |   9 +-
 .../component/geocoder/GeoCoderConstants.java      |   1 +
 .../camel/component/geocoder/GeoCoderEndpoint.java |  92 ++++---
 .../camel/component/geocoder/GeoCoderProducer.java | 268 +++++++++++----------
 ...{GeoCoderConstants.java => GeocoderStatus.java} |  31 +--
 .../geocoder/GeoCoderApiKeyTestBase.java}          |  25 +-
 .../geocoder/GeoCoderComponentAddressTest.java     |  16 +-
 .../geocoder/GeoCoderCurrentAddressTest.java       |   6 +-
 ...ressTest.java => GeoCoderEmptyAddressTest.java} |   8 +-
 .../geocoder/GeoCoderLatLngComponentTest.java      |   5 +-
 .../component/geocoder/GeoCoderProxyTest.java      |  21 +-
 12 files changed, 275 insertions(+), 224 deletions(-)

diff --git a/components/camel-geocoder/pom.xml b/components/camel-geocoder/pom.xml
index 9243244..0302ae3 100644
--- a/components/camel-geocoder/pom.xml
+++ b/components/camel-geocoder/pom.xml
@@ -42,17 +42,12 @@
       <groupId>org.apache.camel</groupId>
       <artifactId>camel-core</artifactId>
     </dependency>
+    <!-- Java client library for Google Maps API Web Services -->
     <dependency>
-      <groupId>com.google.code.geocoder-java</groupId>
-      <artifactId>geocoder-java</artifactId>
-      <version>${geocoder-java-version}</version>
+      <groupId>com.google.maps</groupId>
+      <artifactId>google-maps-services</artifactId>
+      <version>0.2.7</version>
     </dependency>
-    <dependency>
-      <groupId>org.codehaus.jackson</groupId>
-      <artifactId>jackson-mapper-asl</artifactId>
-      <version>${jackson-version}</version>
-    </dependency>
-
     <!-- testing -->
     <dependency>
       <groupId>org.apache.camel</groupId>
@@ -79,6 +74,10 @@
       <artifactId>log4j-slf4j-impl</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>commons-httpclient</groupId>
+      <artifactId>commons-httpclient</artifactId>
+    </dependency>
   </dependencies>
 
   <build>
diff --git a/components/camel-geocoder/src/main/docs/geocoder-component.adoc b/components/camel-geocoder/src/main/docs/geocoder-component.adoc
index a49ba5b..03e3fce 100644
--- a/components/camel-geocoder/src/main/docs/geocoder-component.adoc
+++ b/components/camel-geocoder/src/main/docs/geocoder-component.adoc
@@ -65,10 +65,11 @@ with the following path and query parameters:
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
-| *clientId* (producer) | To use google premium with this client id |  | String
-| *clientKey* (producer) | To use google premium with this client key |  | String
+| *apiKey* (producer) | Google Maps API Key |  | String
+| *clientId* (producer) | Client Id for Google Maps API Premium Plan |  | String
+| *clientKey* (producer) | Private key for Google Maps API Premium Plan |  | String
 | *headersOnly* (producer) | Whether to only enrich the Exchange with headers, and leave the body as-is. | false | boolean
-| *language* (producer) | The language to use. | en | String
+| *language* (producer) | The language in which to return results. | en | String
 | *httpClientConfigurer* (advanced) | Register a custom configuration strategy for new HttpClient instances created by producers or consumers such as to configure authentication mechanisms etc |  | HttpClientConfigurer
 | *httpConnectionManager* (advanced) | To use a custom HttpConnectionManager to manage connections |  | HttpConnectionManager
 | *synchronous* (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean
@@ -121,6 +122,8 @@ Exchange.
 |`CamelGeoCoderCountryLong` |The country long name.
 
 |`CamelGeoCoderCountryShort` |The country short name.
+
+|`CamelGeoCoderPostalCode` |The postal code.
 |=======================================================================
 
 Notice not all headers may be provided depending on available data and
diff --git a/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderConstants.java b/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderConstants.java
index 58b7612..afe0bf5 100644
--- a/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderConstants.java
+++ b/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderConstants.java
@@ -28,6 +28,7 @@ public final class GeoCoderConstants {
     public static final String CITY = "CamelGeoCoderCity";
     public static final String COUNTRY_LONG = "CamelGeoCoderCountryLong";
     public static final String COUNTRY_SHORT = "CamelGeoCoderCountryShort";
+    public static final String POSTAL_CODE = "CamelGeoCoderPostalCode";
 
     private GeoCoderConstants() {
     }
diff --git a/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderEndpoint.java b/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderEndpoint.java
index 0a7b047..a9e0a2a 100644
--- a/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderEndpoint.java
+++ b/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderEndpoint.java
@@ -18,8 +18,7 @@ package org.apache.camel.component.geocoder;
 
 import java.security.InvalidKeyException;
 
-import com.google.code.geocoder.AdvancedGeoCoder;
-import com.google.code.geocoder.Geocoder;
+import com.google.maps.GeoApiContext;
 import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
@@ -48,10 +47,12 @@ public class GeoCoderEndpoint extends DefaultEndpoint {
     private String latlng;
     @UriParam(defaultValue = "en")
     private String language = "en";
-    @UriParam
+    @UriParam(label = "security", secret = true)
     private String clientId;
-    @UriParam
+    @UriParam(label = "security", secret = true)
     private String clientKey;
+    @UriParam(label = "security", secret = true)
+    private String apiKey;
     @UriParam
     private boolean headersOnly;
     @UriParam(label = "proxy")
@@ -158,6 +159,15 @@ public class GeoCoderEndpoint extends DefaultEndpoint {
         this.clientKey = clientKey;
     }
 
+
+    private String getApiKey() {
+        return apiKey;
+    }
+
+    public void setApiKey(String apiKey) {
+        this.apiKey = apiKey;
+    }
+
     /**
      * The proxy host name
      */
@@ -257,42 +267,54 @@ public class GeoCoderEndpoint extends DefaultEndpoint {
         this.httpConnectionManager = httpConnectionManager;
     }
 
-    Geocoder createGeocoder() throws InvalidKeyException {
-        HttpConnectionManager connectionManager = this.httpConnectionManager;
-        if (connectionManager == null) {
-            connectionManager = new MultiThreadedHttpConnectionManager();
-        }
-
-        HttpClient httpClient = new HttpClient(connectionManager);
-        if (proxyHost != null && proxyPort != null) {
-            httpClient.getHostConfiguration().setProxy(proxyHost, proxyPort);
-        }
-
-        // validate that if proxy auth username is given then the proxy auth method is also provided
-        if (proxyAuthUsername != null && proxyAuthMethod == null) {
-            throw new IllegalArgumentException("Option proxyAuthMethod must be provided to use proxy authentication");
-        }
-
-        CompositeHttpConfigurer configurer = new CompositeHttpConfigurer();
-        if (proxyAuthMethod != null) {
-            configureProxyAuth(configurer, proxyAuthMethod, proxyAuthUsername, proxyAuthPassword, proxyAuthDomain, proxyAuthHost);
-        }
-        if (httpClientConfigurer != null) {
-            configurer.addConfigurer(httpClientConfigurer);
-        }
-
-        configurer.configureHttpClient(httpClient);
-
-        Geocoder geocoder;
+    GeoApiContext createGeoApiContext() {
         if (clientId != null) {
-            geocoder = new AdvancedGeoCoder(httpClient, clientId, clientKey);
+            return new GeoApiContext.Builder()
+                    .enterpriseCredentials(clientId, clientKey)
+                    .build();
         } else {
-            geocoder = new AdvancedGeoCoder(httpClient);
+            return new GeoApiContext.Builder()
+                    .apiKey(getApiKey())
+                    .build();
         }
-
-        return geocoder;
     }
 
+//    Geocoder createGeocoder() throws InvalidKeyException {
+//        HttpConnectionManager connectionManager = this.httpConnectionManager;
+//        if (connectionManager == null) {
+//            connectionManager = new MultiThreadedHttpConnectionManager();
+//        }
+//
+//        HttpClient httpClient = new HttpClient(connectionManager);
+//        if (proxyHost != null && proxyPort != null) {
+//            httpClient.getHostConfiguration().setProxy(proxyHost, proxyPort);
+//        }
+//
+//        // validate that if proxy auth username is given then the proxy auth method is also provided
+//        if (proxyAuthUsername != null && proxyAuthMethod == null) {
+//            throw new IllegalArgumentException("Option proxyAuthMethod must be provided to use proxy authentication");
+//        }
+//
+//        CompositeHttpConfigurer configurer = new CompositeHttpConfigurer();
+//        if (proxyAuthMethod != null) {
+//            configureProxyAuth(configurer, proxyAuthMethod, proxyAuthUsername, proxyAuthPassword, proxyAuthDomain, proxyAuthHost);
+//        }
+//        if (httpClientConfigurer != null) {
+//            configurer.addConfigurer(httpClientConfigurer);
+//        }
+//
+//        configurer.configureHttpClient(httpClient);
+//
+//        Geocoder geocoder;
+//        if (clientId != null) {
+//            geocoder = new AdvancedGeoCoder(httpClient, clientId, clientKey);
+//        } else {
+//            geocoder = new AdvancedGeoCoder(httpClient);
+//        }
+//
+//        return geocoder;
+//    }
+
     /**
      * Configures the proxy authentication method to be used
      *
diff --git a/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderProducer.java b/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderProducer.java
index 8e2f480..049170f 100644
--- a/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderProducer.java
+++ b/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderProducer.java
@@ -16,27 +16,28 @@
  */
 package org.apache.camel.component.geocoder;
 
-import java.math.BigDecimal;
-import java.net.URL;
-
-import com.google.code.geocoder.Geocoder;
-import com.google.code.geocoder.model.GeocodeResponse;
-import com.google.code.geocoder.model.GeocoderAddressComponent;
-import com.google.code.geocoder.model.GeocoderRequest;
-import com.google.code.geocoder.model.GeocoderResult;
-import com.google.code.geocoder.model.GeocoderStatus;
-import com.google.code.geocoder.model.LatLng;
+import java.util.Locale;
+
+import com.google.maps.GeoApiContext;
+import com.google.maps.GeocodingApi;
+import com.google.maps.GeolocationApi;
+import com.google.maps.errors.InvalidRequestException;
+import com.google.maps.errors.OverDailyLimitException;
+import com.google.maps.errors.OverQueryLimitException;
+import com.google.maps.errors.RequestDeniedException;
+import com.google.maps.errors.UnknownErrorException;
+import com.google.maps.model.AddressComponent;
+import com.google.maps.model.AddressType;
+import com.google.maps.model.GeocodingResult;
+import com.google.maps.model.GeolocationPayload;
+import com.google.maps.model.GeolocationResult;
+import com.google.maps.model.LatLng;
 import org.apache.camel.Exchange;
 import org.apache.camel.impl.DefaultProducer;
 import org.apache.camel.util.ObjectHelper;
-import org.codehaus.jackson.JsonNode;
-import org.codehaus.jackson.map.ObjectMapper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static org.apache.camel.util.ObjectHelper.isEmpty;
-import static org.apache.camel.util.ObjectHelper.notNull;
-
 /**
  * The GeoCoder producer.
  */
@@ -44,7 +45,7 @@ public class GeoCoderProducer extends DefaultProducer {
     private static final Logger LOG = LoggerFactory.getLogger(GeoCoderProducer.class);
 
     private GeoCoderEndpoint endpoint;
-    private Geocoder geocoder;
+    private GeoApiContext context;
 
     public GeoCoderProducer(GeoCoderEndpoint endpoint) {
         super(endpoint);
@@ -52,152 +53,173 @@ public class GeoCoderProducer extends DefaultProducer {
     }
 
     public void process(Exchange exchange) throws Exception {
-        // header take precedence
-        String address = exchange.getIn().getHeader(GeoCoderConstants.ADDRESS, String.class);
-        if (address == null) {
-            address = endpoint.getAddress();
-        }
+        try {
+            // headers take precedence
+            String address = exchange.getIn().getHeader(GeoCoderConstants.ADDRESS, String.class);
+            if (address == null) {
+                address = endpoint.getAddress();
+            }
 
-        String latlng = exchange.getIn().getHeader(GeoCoderConstants.LATLNG, String.class);
-        if (latlng == null) {
-            latlng = endpoint.getLatlng();
-        }
+            String latlng = exchange.getIn().getHeader(GeoCoderConstants.LATLNG, String.class);
+            if (latlng == null) {
+                latlng = endpoint.getLatlng();
+            }
 
-        if (latlng != null) {
-            GeocoderRequest req = new GeocoderRequest();
-            req.setLanguage(endpoint.getLanguage());
+            if (latlng != null) {
+                String lat = ObjectHelper.before(latlng, ",");
+                String lng = ObjectHelper.after(latlng, ",");
+                LatLng latLng = new LatLng(Double.parseDouble(lat), Double.parseDouble(lng));
 
-            String lat = ObjectHelper.before(latlng, ",");
-            String lng = ObjectHelper.after(latlng, ",");
-            req.setLocation(new LatLng(lat, lng));
+                LOG.debug("Geocode for lat/lng {}", latlng);
+                GeocodingResult[] results = GeocodingApi.reverseGeocode(context, latLng).await();
 
-            LOG.debug("Geocode for lat/lng {}", latlng);
-            GeocodeResponse res = geocoder.geocode(req);
-            LOG.debug("Geocode response {}", res);
+                LOG.debug("Geocode response {}", results);
 
-            if (res != null) {
-                extractGeoResult(res, exchange);
-            }
-        } else if (address != null) {
-
-            // is it current address
-            if ("current".equals(address)) {
-                processCurrentLocation(exchange);
-            } else {
-                LOG.debug("Geocode for address {}", address);
-                GeocoderRequest req = new GeocoderRequest(address, endpoint.getLanguage());
-                GeocodeResponse res = geocoder.geocode(req);
-                LOG.debug("Geocode response {}", res);
-
-                if (res != null) {
-                    extractGeoResult(res, exchange);
+                if (results != null) {
+                    extractGeoResult(results, exchange);
+                }
+
+            } else if (address != null) {
+
+                // is it current address
+                if ("current".equals(address)) {
+                    processCurrentLocation(exchange);
+                } else {
+
+                    LOG.debug("Geocode for address {}", address);
+                    GeocodingResult[] results = GeocodingApi.geocode(context, address).await();
+                    LOG.debug("Geocode response {}", results);
+
+                    if (results != null) {
+                        extractGeoResult(results, exchange);
+                    }
                 }
             }
+        } catch (RequestDeniedException e) {
+            exchange.getIn().setHeader(GeoCoderConstants.STATUS, GeocoderStatus.REQUEST_DENIED);
+        } catch (OverQueryLimitException e) {
+            exchange.getIn().setHeader(GeoCoderConstants.STATUS, GeocoderStatus.OVER_QUERY_LIMIT);
+        } catch (OverDailyLimitException e) {
+            exchange.getIn().setHeader(GeoCoderConstants.STATUS, GeocoderStatus.OVER_DAILY_LIMIT);
+        } catch (InvalidRequestException e) {
+            exchange.getIn().setHeader(GeoCoderConstants.STATUS, GeocoderStatus.INVALID_REQUEST);
+        } catch (UnknownErrorException e) {
+            exchange.getIn().setHeader(GeoCoderConstants.STATUS, GeocoderStatus.UNKNOWN_ERROR);
         }
     }
 
+    /**
+     * Perform geolocation to retrieve LatLng and then perform a geocoding
+     */
     protected void processCurrentLocation(Exchange exchange) throws Exception {
-        LOG.debug("Geocode for current address");
-        String json = exchange.getContext().getTypeConverter().mandatoryConvertTo(String.class, new URL("https://freegeoip.net/json/"));
-        if (isEmpty(json)) {
-            throw new IllegalStateException("Got the unexpected value '" + json + "' for the geolocation");
-        }
-        LOG.debug("Geocode response {}", json);
+        LOG.debug("Geolocation for current location");
+        GeolocationPayload payload = new GeolocationPayload();
+        payload.considerIp = true;
+        GeolocationResult result = GeolocationApi.geolocate(context, payload).await();
 
+        LOG.debug("Geolocation response {}", result);
+        //status
         exchange.getIn().setHeader(GeoCoderConstants.STATUS, GeocoderStatus.OK);
 
-        ObjectMapper mapper = new ObjectMapper();
-        JsonNode node = mapper.readValue(json, JsonNode.class);
-
-        JsonNode latitudeNode = notNull(node.get("latitude"), "latitude");
-        JsonNode longitudeNode = notNull(node.get("longitude"), "longitude");
-        String resLatlng = latitudeNode.asText() + "," + longitudeNode.asText();
+        //latlng
+        String resLatlng = result.location.toString();
         exchange.getIn().setHeader(GeoCoderConstants.LATLNG, resLatlng);
 
-        JsonNode countryCode = node.get("country_code");
-        JsonNode countryName = node.get("country_name");
-        if (countryCode != null) {
-            exchange.getIn().setHeader(GeoCoderConstants.COUNTRY_SHORT, countryCode.asText());
-        }
-        if (countryName != null) {
-            exchange.getIn().setHeader(GeoCoderConstants.COUNTRY_LONG, countryName.asText());
-        }
+        //address - reverse geocode
+        LOG.debug("Geocode - reverse geocode for location {}", resLatlng);
+        GeocodingResult[] results = GeocodingApi.reverseGeocode(context, result.location).await();
 
-        JsonNode regionCode = node.get("region_code");
-        JsonNode regionName = node.get("region_name");
-        if (regionCode != null) {
-            exchange.getIn().setHeader(GeoCoderConstants.REGION_CODE, regionCode.asText());
-        }
-        if (regionName != null) {
-            exchange.getIn().setHeader(GeoCoderConstants.REGION_NAME, regionName.asText());
-        }
+        LOG.debug("Geocode response {}", results);
 
-        JsonNode city = node.get("city");
-        if (city != null) {
-            exchange.getIn().setHeader(GeoCoderConstants.CITY, city.asText());
+        if (results != null) {
+            extractGeoResult(results, exchange);
         }
+    }
 
-        // should we include body
-        if (!endpoint.isHeadersOnly()) {
-            exchange.getIn().setBody(json);
-        }
+    private void setLatLngToExchangeHeader(LatLng location, Exchange exchange) {
+        double resLat = location.lat;
+        double resLng = location.lng;
+        exchange.getIn().setHeader(GeoCoderConstants.LAT, formatLatOrLon(resLat));
+        exchange.getIn().setHeader(GeoCoderConstants.LNG, formatLatOrLon(resLng));
+        String resLatlng = location.toString();
+        exchange.getIn().setHeader(GeoCoderConstants.LATLNG, resLatlng);
     }
 
-    protected void extractGeoResult(GeocodeResponse res, Exchange exchange) {
-        exchange.getIn().setHeader(GeoCoderConstants.STATUS, res.getStatus());
+    protected void extractGeoResult(GeocodingResult[] res, Exchange exchange) {
         // should we include body
         if (!endpoint.isHeadersOnly()) {
             exchange.getIn().setBody(res);
         }
+        //no results
+        if (res.length == 0) {
+            exchange.getIn().setHeader(GeoCoderConstants.STATUS, GeocoderStatus.ZERO_RESULTS);
+            return;
+        }
 
-        if (res.getStatus() == GeocoderStatus.OK) {
-            exchange.getIn().setHeader(GeoCoderConstants.ADDRESS, res.getResults().get(0).getFormattedAddress());
-            // just grab the first element and its lat and lon
-            BigDecimal resLat = res.getResults().get(0).getGeometry().getLocation().getLat();
-            BigDecimal resLon = res.getResults().get(0).getGeometry().getLocation().getLng();
-            exchange.getIn().setHeader(GeoCoderConstants.LAT, resLat.toPlainString());
-            exchange.getIn().setHeader(GeoCoderConstants.LNG, resLon.toPlainString());
-            String resLatlng = resLat.toPlainString() + "," + resLon.toPlainString();
-            exchange.getIn().setHeader(GeoCoderConstants.LATLNG, resLatlng);
-
-            GeocoderAddressComponent country = getCountry(res);
-            if (country != null) {
-                exchange.getIn().setHeader(GeoCoderConstants.COUNTRY_SHORT, country.getShortName());
-                exchange.getIn().setHeader(GeoCoderConstants.COUNTRY_LONG, country.getLongName());
-            }
+        exchange.getIn().setHeader(GeoCoderConstants.STATUS, GeocoderStatus.OK);
 
-            GeocoderAddressComponent city = getCity(res);
-            if (city != null) {
-                exchange.getIn().setHeader(GeoCoderConstants.CITY, city.getLongName());
-            }
+        GeocodingResult first = res[0];
+        exchange.getIn().setHeader(GeoCoderConstants.ADDRESS, first.formattedAddress);
+        // just grab the first element and its lat and lon
+        setLatLngToExchangeHeader(first.geometry.location, exchange);
+
+        //additional details
+        AddressComponent country = getCountry(res);
+        if (country != null) {
+            exchange.getIn().setHeader(GeoCoderConstants.COUNTRY_SHORT, country.shortName);
+            exchange.getIn().setHeader(GeoCoderConstants.COUNTRY_LONG, country.longName);
         }
-    }
 
-    private static GeocoderAddressComponent getCountry(GeocodeResponse res) {
-        for (GeocoderResult result : res.getResults()) {
-            for (String type : result.getTypes()) {
-                if ("country".equals(type)) {
-                    return result.getAddressComponents().get(0);
-                }
-            }
+        AddressComponent city = getCity(res);
+        if (city != null) {
+            exchange.getIn().setHeader(GeoCoderConstants.CITY, city.longName);
         }
-        return null;
+
+        AddressComponent postalCode = getPostalCode(res);
+        if (postalCode != null) {
+            exchange.getIn().setHeader(GeoCoderConstants.POSTAL_CODE, postalCode.shortName);
+        }
+
+        AddressComponent region = getRegion(res);
+        if (region != null) {
+            exchange.getIn().setHeader(GeoCoderConstants.REGION_CODE, region.shortName);
+            exchange.getIn().setHeader(GeoCoderConstants.REGION_NAME, region.longName);
+        }
+    }
+
+    private String formatLatOrLon(double value) {
+        return String.format(Locale.ENGLISH, "%.8f", value);
     }
 
-    private static GeocoderAddressComponent getCity(GeocodeResponse res) {
-        for (GeocoderResult result : res.getResults()) {
-            for (String type : result.getTypes()) {
-                if ("locality".equals(type)) {
-                    return result.getAddressComponents().get(0);
+    private static AddressComponent getComponent(GeocodingResult[] results, AddressType addressType) {
+        for (GeocodingResult result : results) {
+            for (AddressType type : result.types) {
+                if (type == addressType && result.addressComponents.length > 0) {
+                    return result.addressComponents[0];
                 }
             }
         }
         return null;
     }
 
-    @Override
-    protected void doStart() throws Exception {
-        geocoder = endpoint.createGeocoder();
+    private static AddressComponent getCountry(GeocodingResult[] res) {
+        return getComponent(res, AddressType.COUNTRY);
+    }
+
+    private static AddressComponent getCity(GeocodingResult[] res) {
+        return getComponent(res, AddressType.LOCALITY);
     }
 
+    private static AddressComponent getPostalCode(GeocodingResult[] res) {
+        return getComponent(res, AddressType.POSTAL_CODE);
+    }
+
+    private static AddressComponent getRegion(GeocodingResult[] res) {
+        return getComponent(res, AddressType.ADMINISTRATIVE_AREA_LEVEL_1);
+    }
+
+    @Override
+    protected void doStart() {
+        context = endpoint.createGeoApiContext();
+    }
 }
diff --git a/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderConstants.java b/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeocoderStatus.java
similarity index 53%
copy from components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderConstants.java
copy to components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeocoderStatus.java
index 58b7612..d8132dd 100644
--- a/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderConstants.java
+++ b/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeocoderStatus.java
@@ -14,22 +14,25 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.component.geocoder;
 
-public final class GeoCoderConstants {
+package org.apache.camel.component.geocoder;
 
-    public static final String ADDRESS = "CamelGeoCoderAddress";
-    public static final String LATLNG = "CamelGeoCoderLatlng";
-    public static final String LAT = "CamelGeoCoderLat";
-    public static final String LNG = "CamelGeoCoderLng";
-    public static final String STATUS = "CamelGeoCoderStatus";
-    public static final String REGION_CODE = "CamelGeoCoderRegionCode";
-    public static final String REGION_NAME = "CamelGeoCoderRegionName";
-    public static final String CITY = "CamelGeoCoderCity";
-    public static final String COUNTRY_LONG = "CamelGeoCoderCountryLong";
-    public static final String COUNTRY_SHORT = "CamelGeoCoderCountryShort";
+public enum GeocoderStatus {
+    ERROR,
+    INVALID_REQUEST,
+    ACCESS_NOT_CONFIGURED,
+    OK,
+    OVER_QUERY_LIMIT,
+    OVER_DAILY_LIMIT,
+    REQUEST_DENIED,
+    UNKNOWN_ERROR,
+    ZERO_RESULTS;
 
-    private GeoCoderConstants() {
+    public String value() {
+        return name();
     }
 
-}
+    public static GeocoderStatus fromValue(String v) {
+        return valueOf(v);
+    }
+}
\ No newline at end of file
diff --git a/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderConstants.java b/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderApiKeyTestBase.java
similarity index 54%
copy from components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderConstants.java
copy to components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderApiKeyTestBase.java
index 58b7612..409ae7b 100644
--- a/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderConstants.java
+++ b/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderApiKeyTestBase.java
@@ -16,20 +16,21 @@
  */
 package org.apache.camel.component.geocoder;
 
-public final class GeoCoderConstants {
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.AssumptionViolatedException;
+import org.junit.Before;
 
-    public static final String ADDRESS = "CamelGeoCoderAddress";
-    public static final String LATLNG = "CamelGeoCoderLatlng";
-    public static final String LAT = "CamelGeoCoderLat";
-    public static final String LNG = "CamelGeoCoderLng";
-    public static final String STATUS = "CamelGeoCoderStatus";
-    public static final String REGION_CODE = "CamelGeoCoderRegionCode";
-    public static final String REGION_NAME = "CamelGeoCoderRegionName";
-    public static final String CITY = "CamelGeoCoderCity";
-    public static final String COUNTRY_LONG = "CamelGeoCoderCountryLong";
-    public static final String COUNTRY_SHORT = "CamelGeoCoderCountryShort";
+public class GeoCoderApiKeyTestBase extends CamelTestSupport {
 
-    private GeoCoderConstants() {
+    @Before
+    public void before() {
+        String apiKey = getApiKey();
+        if (apiKey == null) {
+            throw new AssumptionViolatedException("API key not found in CAMEL_GEOCODER_APIKEY environment variable, skipping this test");
+        }
     }
 
+    protected String getApiKey() {
+        return System.getenv("CAMEL_GEOCODER_APIKEYx");
+    }
 }
diff --git a/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderComponentAddressTest.java b/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderComponentAddressTest.java
index 16d8bd6..1778961 100644
--- a/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderComponentAddressTest.java
+++ b/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderComponentAddressTest.java
@@ -18,19 +18,19 @@ package org.apache.camel.component.geocoder;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
-public class GeoCoderComponentAddressTest extends CamelTestSupport {
+public class GeoCoderComponentAddressTest extends GeoCoderApiKeyTestBase {
 
     @Test
     public void testGeoCoder() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(1);
 
+        mock.expectedHeaderReceived(GeoCoderConstants.LATLNG, "55.67609680,12.56833720");
         // the address header overrides the endpoint configuration
-        template.sendBodyAndHeader("direct:start", "Hello", GeoCoderConstants.ADDRESS, "Copenhagen, Denmark");
-        
+        template.sendBodyAndHeader("direct:start", "Hello", GeoCoderConstants.ADDRESS, " ");
+
         assertMockEndpointsSatisfied();
     }
 
@@ -39,10 +39,10 @@ public class GeoCoderComponentAddressTest extends CamelTestSupport {
         return new RouteBuilder() {
             public void configure() {
                 from("direct:start")
-                    .to("geocoder:address:Paris, France")
-                    .to("log:result")
-                    .log("Location ${header.CamelGeocoderAddress} is at lat/lng: ${header.CamelGeocoderLatlng} in city ${header.CamelGeocoderCity}")
-                    .to("mock:result");
+                        .to("geocoder:address: empty?apiKey=" + getApiKey())
+                        .to("log:result")
+                        .log("Location ${header.CamelGeocoderAddress} is at lat/lng: ${header.CamelGeocoderLatlng} in city ${header.CamelGeocoderCity}")
+                        .to("mock:result");
             }
         };
     }
diff --git a/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderCurrentAddressTest.java b/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderCurrentAddressTest.java
index 23cd1d4..ea666d1 100644
--- a/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderCurrentAddressTest.java
+++ b/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderCurrentAddressTest.java
@@ -18,14 +18,14 @@ package org.apache.camel.component.geocoder;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
-public class GeoCoderCurrentAddressTest extends CamelTestSupport {
+public class GeoCoderCurrentAddressTest extends GeoCoderApiKeyTestBase  {
 
     @Test
     public void testGeoCoder() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
         mock.expectedBodiesReceived("Hello");
         mock.message(0).header(GeoCoderConstants.LATLNG).isNotNull();
 
@@ -39,7 +39,7 @@ public class GeoCoderCurrentAddressTest extends CamelTestSupport {
         return new RouteBuilder() {
             public void configure() {
                 from("direct:start")
-                    .to("geocoder:address:current?headersOnly=true")
+                    .to("geocoder:address:current?headersOnly=true&apiKey=" + getApiKey())
                     .to("log:result")
                     .log("You are at ${header.CamelGeoCoderLatlng} in city ${header.CamelGeoCoderCity} in country ${header.CamelGeoCoderCountryLong}")
                     .to("mock:result");
diff --git a/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderComponentAddressTest.java b/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderEmptyAddressTest.java
similarity index 87%
copy from components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderComponentAddressTest.java
copy to components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderEmptyAddressTest.java
index 16d8bd6..93be10a 100644
--- a/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderComponentAddressTest.java
+++ b/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderEmptyAddressTest.java
@@ -18,18 +18,18 @@ package org.apache.camel.component.geocoder;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
-public class GeoCoderComponentAddressTest extends CamelTestSupport {
+public class GeoCoderEmptyAddressTest extends GeoCoderApiKeyTestBase {
 
     @Test
     public void testGeoCoder() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(1);
 
+        mock.expectedHeaderReceived(GeoCoderConstants.STATUS, GeocoderStatus.ZERO_RESULTS);
         // the address header overrides the endpoint configuration
-        template.sendBodyAndHeader("direct:start", "Hello", GeoCoderConstants.ADDRESS, "Copenhagen, Denmark");
+        template.sendBodyAndHeader("direct:start", "Hello", GeoCoderConstants.ADDRESS, " ");
         
         assertMockEndpointsSatisfied();
     }
@@ -39,7 +39,7 @@ public class GeoCoderComponentAddressTest extends CamelTestSupport {
         return new RouteBuilder() {
             public void configure() {
                 from("direct:start")
-                    .to("geocoder:address:Paris, France")
+                    .to("geocoder:address: ?apiKey=" + getApiKey())
                     .to("log:result")
                     .log("Location ${header.CamelGeocoderAddress} is at lat/lng: ${header.CamelGeocoderLatlng} in city ${header.CamelGeocoderCity}")
                     .to("mock:result");
diff --git a/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderLatLngComponentTest.java b/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderLatLngComponentTest.java
index 314e223..0e816fd 100644
--- a/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderLatLngComponentTest.java
+++ b/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderLatLngComponentTest.java
@@ -18,10 +18,9 @@ package org.apache.camel.component.geocoder;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
-public class GeoCoderLatLngComponentTest extends CamelTestSupport {
+public class GeoCoderLatLngComponentTest extends GeoCoderApiKeyTestBase {
 
     @Test
     public void testGeoCoder() throws Exception {
@@ -41,7 +40,7 @@ public class GeoCoderLatLngComponentTest extends CamelTestSupport {
         return new RouteBuilder() {
             public void configure() {
                 from("direct:start")
-                    .to("geocoder:latlng:40.714224,-73.961452")
+                    .to("geocoder:latlng:40.714224,-73.961452?apiKey=" + getApiKey())
                     .to("log:result")
                     .log("Location ${header.CamelGeocoderAddress} is at lat/lng: ${header.CamelGeocoderLatlng}"
                         + " and in city ${header.CamelGeoCoderCity} in country ${header.CamelGeoCoderCountryLong}")
diff --git a/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderProxyTest.java b/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderProxyTest.java
index 0513327..97b4d2d 100644
--- a/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderProxyTest.java
+++ b/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderProxyTest.java
@@ -16,15 +16,17 @@
  */
 package org.apache.camel.component.geocoder;
 
-import com.google.code.geocoder.Geocoder;
-import com.google.code.geocoder.model.GeocodeResponse;
-import com.google.code.geocoder.model.GeocoderRequest;
-import com.google.code.geocoder.model.LatLng;
+
+import com.google.maps.GeoApiContext;
+import com.google.maps.GeocodingApi;
+import com.google.maps.GeocodingApiRequest;
+import com.google.maps.model.GeocodingResult;
+import com.google.maps.model.LatLng;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Ignore;
 import org.junit.Test;
 
-@Ignore("This test should be executed manually")
+@Ignore("This test should be executed manually with a proxy set up")
 public class GeoCoderProxyTest extends CamelTestSupport {
 
     @Test
@@ -33,11 +35,10 @@ public class GeoCoderProxyTest extends CamelTestSupport {
             "geocoder:address:current?headersOnly=true&proxyHost=localhost&proxyPort=3128&proxyAuthMethod=Basic&proxyAuthUsername=proxy&proxyAuthPassword=proxy",
             GeoCoderEndpoint.class);
 
-        Geocoder geocoder = endpoint.createGeocoder();
-        GeocoderRequest req = new GeocoderRequest();
-        req.setLocation(new LatLng("45.4643", "9.1895"));
-        GeocodeResponse res = geocoder.geocode(req);
+        GeoApiContext context = endpoint.createGeoApiContext();
+        GeocodingApiRequest geocodingApiRequest = GeocodingApi.reverseGeocode(context, new LatLng(45.4643, 9.1895));
+        GeocodingResult[] results = geocodingApiRequest.await();
 
-        log.info("Response {} ", res);
+        log.info("Response {}", results);
     }
 }


[camel] 02/04: implemented proxy support for GeoCoderEndpoint, removed commons-httpclient

Posted by on...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

onders pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit bf61db52581ca187e8615eafee1d745a0db0d239
Author: jborza <jb...@gmail.com>
AuthorDate: Sun Jul 8 08:58:15 2018 +0200

    implemented proxy support for GeoCoderEndpoint, removed commons-httpclient
---
 components/camel-geocoder/pom.xml                  |   4 -
 .../src/main/docs/geocoder-component.adoc          |   6 +-
 .../camel/component/geocoder/GeoCoderEndpoint.java | 141 +++++----------------
 .../http/AuthenticationHttpClientConfigurer.java   |  54 --------
 .../geocoder/http/AuthenticationMethod.java        |   2 +-
 .../geocoder/http/CompositeHttpConfigurer.java     |  50 --------
 .../geocoder/http/HttpClientConfigurer.java        |  35 -----
 .../component/geocoder/GeoCoderApiKeyTestBase.java |   2 +-
 .../component/geocoder/GeoCoderProxyTest.java      |  20 ++-
 9 files changed, 50 insertions(+), 264 deletions(-)

diff --git a/components/camel-geocoder/pom.xml b/components/camel-geocoder/pom.xml
index 0302ae3..ed56b89 100644
--- a/components/camel-geocoder/pom.xml
+++ b/components/camel-geocoder/pom.xml
@@ -74,10 +74,6 @@
       <artifactId>log4j-slf4j-impl</artifactId>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>commons-httpclient</groupId>
-      <artifactId>commons-httpclient</artifactId>
-    </dependency>
   </dependencies>
 
   <build>
diff --git a/components/camel-geocoder/src/main/docs/geocoder-component.adoc b/components/camel-geocoder/src/main/docs/geocoder-component.adoc
index 03e3fce..e0d2b00 100644
--- a/components/camel-geocoder/src/main/docs/geocoder-component.adoc
+++ b/components/camel-geocoder/src/main/docs/geocoder-component.adoc
@@ -70,12 +70,8 @@ with the following path and query parameters:
 | *clientKey* (producer) | Private key for Google Maps API Premium Plan |  | String
 | *headersOnly* (producer) | Whether to only enrich the Exchange with headers, and leave the body as-is. | false | boolean
 | *language* (producer) | The language in which to return results. | en | String
-| *httpClientConfigurer* (advanced) | Register a custom configuration strategy for new HttpClient instances created by producers or consumers such as to configure authentication mechanisms etc |  | HttpClientConfigurer
-| *httpConnectionManager* (advanced) | To use a custom HttpConnectionManager to manage connections |  | HttpConnectionManager
 | *synchronous* (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean
-| *proxyAuthDomain* (proxy) | Domain for proxy NTML authentication |  | String
-| *proxyAuthHost* (proxy) | Optional host for proxy NTML authentication |  | String
-| *proxyAuthMethod* (proxy) | Authentication method for proxy, either as Basic, Digest or NTLM. |  | String
+| *proxyAuthMethod* (proxy) | Authentication method for proxy, either as Basic or Digest. |  | String
 | *proxyAuthPassword* (proxy) | Password for proxy authentication |  | String
 | *proxyAuthUsername* (proxy) | Username for proxy authentication |  | String
 | *proxyHost* (proxy) | The proxy host name |  | String
diff --git a/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderEndpoint.java b/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderEndpoint.java
index a9e0a2a..c1e4595 100644
--- a/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderEndpoint.java
+++ b/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/GeoCoderEndpoint.java
@@ -6,7 +6,7 @@
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,24 +16,18 @@
  */
 package org.apache.camel.component.geocoder;
 
-import java.security.InvalidKeyException;
-
 import com.google.maps.GeoApiContext;
 import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
-import org.apache.camel.component.geocoder.http.AuthenticationHttpClientConfigurer;
 import org.apache.camel.component.geocoder.http.AuthenticationMethod;
-import org.apache.camel.component.geocoder.http.CompositeHttpConfigurer;
-import org.apache.camel.component.geocoder.http.HttpClientConfigurer;
 import org.apache.camel.impl.DefaultEndpoint;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriPath;
-import org.apache.camel.util.ObjectHelper;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpConnectionManager;
-import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
+
+import java.net.InetSocketAddress;
+import java.net.Proxy;
 
 /**
  * The geocoder component is used for looking up geocodes (latitude and longitude) for a given address, or reverse lookup.
@@ -69,10 +63,6 @@ public class GeoCoderEndpoint extends DefaultEndpoint {
     private String proxyAuthDomain;
     @UriParam(label = "proxy")
     private String proxyAuthHost;
-    @UriParam(label = "advanced")
-    private HttpClientConfigurer httpClientConfigurer;
-    @UriParam(label = "advanced")
-    private HttpConnectionManager httpConnectionManager;
 
     public GeoCoderEndpoint() {
     }
@@ -242,113 +232,42 @@ public class GeoCoderEndpoint extends DefaultEndpoint {
         this.proxyAuthHost = proxyAuthHost;
     }
 
-    public HttpClientConfigurer getHttpClientConfigurer() {
-        return httpClientConfigurer;
-    }
-
-    /**
-     * Register a custom configuration strategy for new {@link HttpClient} instances
-     * created by producers or consumers such as to configure authentication mechanisms etc
-     *
-     * @param httpClientConfigurer the strategy for configuring new {@link HttpClient} instances
-     */
-    public void setHttpClientConfigurer(HttpClientConfigurer httpClientConfigurer) {
-        this.httpClientConfigurer = httpClientConfigurer;
-    }
-
-    public HttpConnectionManager getHttpConnectionManager() {
-        return httpConnectionManager;
-    }
-
-    /**
-     * To use a custom HttpConnectionManager to manage connections
-     */
-    public void setHttpConnectionManager(HttpConnectionManager httpConnectionManager) {
-        this.httpConnectionManager = httpConnectionManager;
-    }
-
     GeoApiContext createGeoApiContext() {
+        GeoApiContext.Builder builder = new GeoApiContext.Builder();
         if (clientId != null) {
-            return new GeoApiContext.Builder()
-                    .enterpriseCredentials(clientId, clientKey)
-                    .build();
+            builder = builder.enterpriseCredentials(clientId, clientKey);
         } else {
-            return new GeoApiContext.Builder()
-                    .apiKey(getApiKey())
-                    .build();
+            builder = builder.apiKey(getApiKey());
         }
+        if (isProxyDefined()) {
+            builder = builder.proxy(createProxy());
+            if (isProxyAuthDefined()) {
+                builder = configureProxyAuth(builder);
+            }
+        }
+        return builder.build();
     }
 
-//    Geocoder createGeocoder() throws InvalidKeyException {
-//        HttpConnectionManager connectionManager = this.httpConnectionManager;
-//        if (connectionManager == null) {
-//            connectionManager = new MultiThreadedHttpConnectionManager();
-//        }
-//
-//        HttpClient httpClient = new HttpClient(connectionManager);
-//        if (proxyHost != null && proxyPort != null) {
-//            httpClient.getHostConfiguration().setProxy(proxyHost, proxyPort);
-//        }
-//
-//        // validate that if proxy auth username is given then the proxy auth method is also provided
-//        if (proxyAuthUsername != null && proxyAuthMethod == null) {
-//            throw new IllegalArgumentException("Option proxyAuthMethod must be provided to use proxy authentication");
-//        }
-//
-//        CompositeHttpConfigurer configurer = new CompositeHttpConfigurer();
-//        if (proxyAuthMethod != null) {
-//            configureProxyAuth(configurer, proxyAuthMethod, proxyAuthUsername, proxyAuthPassword, proxyAuthDomain, proxyAuthHost);
-//        }
-//        if (httpClientConfigurer != null) {
-//            configurer.addConfigurer(httpClientConfigurer);
-//        }
-//
-//        configurer.configureHttpClient(httpClient);
-//
-//        Geocoder geocoder;
-//        if (clientId != null) {
-//            geocoder = new AdvancedGeoCoder(httpClient, clientId, clientKey);
-//        } else {
-//            geocoder = new AdvancedGeoCoder(httpClient);
-//        }
-//
-//        return geocoder;
-//    }
-
-    /**
-     * Configures the proxy authentication method to be used
-     *
-     * @return configurer to used
-     */
-    protected CompositeHttpConfigurer configureProxyAuth(CompositeHttpConfigurer configurer,
-            String authMethod, String username, String password, String domain, String host) {
-
-        // no proxy auth is in use
-        if (username == null && authMethod == null) {
-            return configurer;
+    private GeoApiContext.Builder configureProxyAuth(GeoApiContext.Builder builder) {
+        AuthenticationMethod auth = getCamelContext().getTypeConverter().convertTo(AuthenticationMethod.class, proxyAuthMethod);
+        if (auth == AuthenticationMethod.Basic || auth == AuthenticationMethod.Digest) {
+            builder = builder.proxyAuthentication(proxyAuthUsername, proxyAuthPassword);
         }
-
-        // validate mandatory options given
-        if (username != null && authMethod == null) {
-            throw new IllegalArgumentException("Option proxyAuthMethod must be provided to use proxy authentication");
+        else{
+            throw new IllegalArgumentException("Unknown proxyAuthMethod " + proxyAuthMethod);
         }
+        return builder;
+    }
 
-        ObjectHelper.notNull(authMethod, "proxyAuthMethod");
-        ObjectHelper.notNull(username, "proxyAuthUsername");
-        ObjectHelper.notNull(password, "proxyAuthPassword");
-
-        AuthenticationMethod auth = getCamelContext().getTypeConverter().convertTo(AuthenticationMethod.class, authMethod);
+    private Proxy createProxy() {
+        return new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort));
+    }
 
-        if (auth == AuthenticationMethod.Basic || auth == AuthenticationMethod.Digest) {
-            configurer.addConfigurer(AuthenticationHttpClientConfigurer.basicAutenticationConfigurer(true, username, password));
-            return configurer;
-        } else if (auth == AuthenticationMethod.NTLM) {
-            // domain is mandatory for NTML
-            ObjectHelper.notNull(domain, "proxyAuthDomain");
-            configurer.addConfigurer(AuthenticationHttpClientConfigurer.ntlmAutenticationConfigurer(true, username, password, domain, host));
-            return configurer;
-        }
+    private boolean isProxyDefined() {
+        return proxyHost != null && proxyPort != null;
+    }
 
-        throw new IllegalArgumentException("Unknown proxyAuthMethod " + authMethod);
+    private boolean isProxyAuthDefined() {
+        return proxyAuthMethod != null;
     }
 }
diff --git a/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/http/AuthenticationHttpClientConfigurer.java b/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/http/AuthenticationHttpClientConfigurer.java
deleted file mode 100644
index 6ee7890..0000000
--- a/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/http/AuthenticationHttpClientConfigurer.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.geocoder.http;
-
-import org.apache.commons.httpclient.Credentials;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.NTCredentials;
-import org.apache.commons.httpclient.UsernamePasswordCredentials;
-import org.apache.commons.httpclient.auth.AuthScope;
-
-
-public final class AuthenticationHttpClientConfigurer implements HttpClientConfigurer {
-
-    private final boolean proxy;
-    private final Credentials credentials;
-
-    private AuthenticationHttpClientConfigurer(boolean proxy, Credentials credentials) {
-        this.proxy = proxy;
-        this.credentials = credentials;
-    }
-
-    @Override
-    public HttpClient configureHttpClient(HttpClient client) {
-        if (proxy) {
-            client.getState().setProxyCredentials(AuthScope.ANY, this.credentials);
-        } else {
-            client.getState().setCredentials(AuthScope.ANY, this.credentials);
-        }
-
-        return client;
-    }
-
-    public static HttpClientConfigurer basicAutenticationConfigurer(boolean proxy, String user, String pwd) {
-        return new AuthenticationHttpClientConfigurer(proxy, new UsernamePasswordCredentials(user, pwd));
-    }
-
-    public static HttpClientConfigurer ntlmAutenticationConfigurer(boolean proxy, String user, String pwd, String domain, String host) {
-        return new AuthenticationHttpClientConfigurer(proxy, new NTCredentials(user, pwd, host, domain));
-    }
-}
diff --git a/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/http/AuthenticationMethod.java b/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/http/AuthenticationMethod.java
index 0e07b4a..a3f294e 100644
--- a/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/http/AuthenticationMethod.java
+++ b/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/http/AuthenticationMethod.java
@@ -23,5 +23,5 @@ package org.apache.camel.component.geocoder.http;
  */
 public enum AuthenticationMethod {
 
-    Basic, Digest, NTLM
+    Basic, Digest
 }
diff --git a/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/http/CompositeHttpConfigurer.java b/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/http/CompositeHttpConfigurer.java
deleted file mode 100644
index 182c192..0000000
--- a/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/http/CompositeHttpConfigurer.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.geocoder.http;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.commons.httpclient.HttpClient;
-
-public class CompositeHttpConfigurer implements HttpClientConfigurer {
-    
-    private final List<HttpClientConfigurer> configurers = new ArrayList<>();
-    
-    public void addConfigurer(HttpClientConfigurer configurer) {
-        if (configurer != null) {
-            configurers.add(configurer);
-        }
-    }
-    
-    public void removeConfigurer(HttpClientConfigurer configurer) {
-        configurers.remove(configurer);
-    }
-
-    public HttpClient configureHttpClient(HttpClient client) {
-        for (HttpClientConfigurer configurer : configurers) {
-            configurer.configureHttpClient(client);
-        }
-
-        return client;
-    }
-
-    public List<HttpClientConfigurer> getConfigurers() {
-        return Collections.unmodifiableList(configurers);
-    }
-}
diff --git a/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/http/HttpClientConfigurer.java b/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/http/HttpClientConfigurer.java
deleted file mode 100644
index 0d00269..0000000
--- a/components/camel-geocoder/src/main/java/org/apache/camel/component/geocoder/http/HttpClientConfigurer.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.geocoder.http;
-
-import org.apache.commons.httpclient.HttpClient;
-
-/**
- * A pluggable strategy for configuring the HttpClient used by this component
- *
- * @version 
- */
-public interface HttpClientConfigurer {
-
-    /**
-     * Configure the HttpClient such as setting the authentication or proxying details
-     *
-     * @param client the client
-     * @return the client
-     */
-    HttpClient configureHttpClient(HttpClient client);
-}
diff --git a/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderApiKeyTestBase.java b/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderApiKeyTestBase.java
index 409ae7b..ff7e9f8 100644
--- a/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderApiKeyTestBase.java
+++ b/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderApiKeyTestBase.java
@@ -31,6 +31,6 @@ public class GeoCoderApiKeyTestBase extends CamelTestSupport {
     }
 
     protected String getApiKey() {
-        return System.getenv("CAMEL_GEOCODER_APIKEYx");
+        return System.getenv("CAMEL_GEOCODER_APIKEY");
     }
 }
diff --git a/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderProxyTest.java b/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderProxyTest.java
index 97b4d2d..58721f7 100644
--- a/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderProxyTest.java
+++ b/components/camel-geocoder/src/test/java/org/apache/camel/component/geocoder/GeoCoderProxyTest.java
@@ -27,12 +27,12 @@ import org.junit.Ignore;
 import org.junit.Test;
 
 @Ignore("This test should be executed manually with a proxy set up")
-public class GeoCoderProxyTest extends CamelTestSupport {
+public class GeoCoderProxyTest extends GeoCoderApiKeyTestBase {
 
     @Test
-    public void testGeoCoder() throws Exception {
+    public void testGeoCoderProxyNoAuth() throws Exception {
         GeoCoderEndpoint endpoint = context.getEndpoint(
-            "geocoder:address:current?headersOnly=true&proxyHost=localhost&proxyPort=3128&proxyAuthMethod=Basic&proxyAuthUsername=proxy&proxyAuthPassword=proxy",
+            "geocoder:address:current?headersOnly=true&proxyHost=localhost&proxyPort=8888&apiKey="+getApiKey(),
             GeoCoderEndpoint.class);
 
         GeoApiContext context = endpoint.createGeoApiContext();
@@ -41,4 +41,18 @@ public class GeoCoderProxyTest extends CamelTestSupport {
 
         log.info("Response {}", results);
     }
+
+    @Test
+    public void testGeoCoderWithAuth() throws Exception {
+        GeoCoderEndpoint endpoint = context.getEndpoint(
+                "geocoder:address:current?headersOnly=true&proxyHost=localhost&proxyPort=8888&proxyAuthMethod=Basic&proxyAuthUsername=proxy&proxyAuthPassword=proxy&apiKey="+getApiKey(),
+                GeoCoderEndpoint.class);
+
+        GeoApiContext context = endpoint.createGeoApiContext();
+        GeocodingApiRequest geocodingApiRequest = GeocodingApi.reverseGeocode(context, new LatLng(45.4643, 9.1895));
+        GeocodingResult[] results = geocodingApiRequest.await();
+
+        log.info("Response {}", results);
+    }
+
 }