You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2018/07/10 09:01:54 UTC
[camel] branch master updated: CAMEL-12554 - Fixed camel-example
spring-boot for camel-geocoder
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new 9fd6f4f CAMEL-12554 - Fixed camel-example spring-boot for camel-geocoder
9fd6f4f is described below
commit 9fd6f4f8bd663eb5cbf512ca5c873d1a3091970e
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Jul 10 11:01:06 2018 +0200
CAMEL-12554 - Fixed camel-example spring-boot for camel-geocoder
---
.../example/springboot/geocoder/CamelGeocoderRoute.java | 8 +++++---
.../example/springboot/geocoder/ApplicationTest.java | 16 +++++++---------
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/examples/camel-example-spring-boot-geocoder/src/main/java/org/apache/camel/example/springboot/geocoder/CamelGeocoderRoute.java b/examples/camel-example-spring-boot-geocoder/src/main/java/org/apache/camel/example/springboot/geocoder/CamelGeocoderRoute.java
index c311ff2..7210d75 100644
--- a/examples/camel-example-spring-boot-geocoder/src/main/java/org/apache/camel/example/springboot/geocoder/CamelGeocoderRoute.java
+++ b/examples/camel-example-spring-boot-geocoder/src/main/java/org/apache/camel/example/springboot/geocoder/CamelGeocoderRoute.java
@@ -16,10 +16,12 @@
*/
package org.apache.camel.example.springboot.geocoder;
-import com.google.code.geocoder.model.GeocodeResponse;
+
import org.apache.camel.builder.RouteBuilder;
import org.springframework.stereotype.Component;
+import com.google.maps.model.GeocodingResult;
+
import static org.apache.camel.model.rest.RestParamType.query;
/**
@@ -36,11 +38,11 @@ public class CamelGeocoderRoute extends RouteBuilder {
.consumes("application/json")
.produces("application/json")
- .get().description("Geocoder address lookup").outType(GeocodeResponse.class)
+ .get().description("Geocoder address lookup").outType(GeocodingResult[].class)
.param().name("address").type(query).description("The address to lookup").dataType("string").endParam()
.responseMessage().code(200).message("Geocoder successful").endResponseMessage()
// call the geocoder to lookup details from the provided address
- .toD("geocoder:address:${header.address}");
+ .toD("geocoder:address:${header.address})");
}
}
diff --git a/examples/camel-example-spring-boot-geocoder/src/test/java/org/apache/camel/example/springboot/geocoder/ApplicationTest.java b/examples/camel-example-spring-boot-geocoder/src/test/java/org/apache/camel/example/springboot/geocoder/ApplicationTest.java
index fb7a3a4..ece24ce 100644
--- a/examples/camel-example-spring-boot-geocoder/src/test/java/org/apache/camel/example/springboot/geocoder/ApplicationTest.java
+++ b/examples/camel-example-spring-boot-geocoder/src/test/java/org/apache/camel/example/springboot/geocoder/ApplicationTest.java
@@ -17,8 +17,7 @@
package org.apache.camel.example.springboot.geocoder;
-import com.google.code.geocoder.model.GeocodeResponse;
-import com.google.code.geocoder.model.GeocoderStatus;
+
import org.apache.camel.CamelContext;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -32,8 +31,10 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit4.SpringRunner;
+import com.google.maps.model.GeocodingResult;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertNotNull;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@@ -47,13 +48,10 @@ public class ApplicationTest {
@Test
public void geocoderAddressTest() {
- ResponseEntity<GeocodeResponse> response = restTemplate.exchange("/camel/geocoder?address=Paris",
- HttpMethod.GET, null, new ParameterizedTypeReference<GeocodeResponse>() { });
+ ResponseEntity<GeocodingResult[]> response = restTemplate.exchange("/camel/geocoder?address=Paris",
+ HttpMethod.GET, null, new ParameterizedTypeReference<GeocodingResult[]>() { });
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
- GeocodeResponse res = response.getBody();
- assertThat(res.getStatus()).isEqualTo(GeocoderStatus.OK);
- assertThat(res.getResults()).isNotEmpty();
- assertThat(res.getResults()).element(0)
- .hasFieldOrPropertyWithValue("formattedAddress", "Paris, France");
+ GeocodingResult[] res = response.getBody();
+ assertNotNull(res);
}
}
\ No newline at end of file