Updated Branches:
  refs/heads/master 1995e574c -> 46a43b371

Polished the code base of the new Camel Weather component.

Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/46a43b37
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/46a43b37
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/46a43b37

Branch: refs/heads/master
Commit: 46a43b371a0b19ac0c546ca000f9565b0777e738
Parents: 1995e57
Author: Babak Vahdat <[email protected]>
Authored: Tue May 28 07:45:53 2013 +0200
Committer: Babak Vahdat <[email protected]>
Committed: Tue May 28 07:45:53 2013 +0200

----------------------------------------------------------------------
 .../component/weather/WeatherConfiguration.java    |   17 ++++++++-------
 .../camel/component/weather/WeatherEndpoint.java   |    6 ++--
 .../component/weather/BaseWeatherConsumerTest.java |    1 +
 3 files changed, 13 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/46a43b37/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherConfiguration.java
----------------------------------------------------------------------
diff --git 
a/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherConfiguration.java
 
b/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherConfiguration.java
index 08066e1..0496951 100644
--- 
a/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherConfiguration.java
+++ 
b/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherConfiguration.java
@@ -35,7 +35,7 @@ public class WeatherConfiguration {
     private String period = "";
     @UriParam
     private WeatherUnits units = METRIC;
-    private WeatherComponent component;
+    private final WeatherComponent component;
 
     public WeatherConfiguration(WeatherComponent component) {
         this.component = notNull(component, "component");
@@ -75,8 +75,9 @@ public class WeatherConfiguration {
     }
 
     public String getQuery() throws Exception {
-        String result = "http://api.openweathermap.org/data/2.5/";;
-        String location = "";
+        String answer = "http://api.openweathermap.org/data/2.5/";;
+
+        String location;
         if (isEmpty(getLocation())) {
             location = getGeoLocation();
         } else {
@@ -85,13 +86,13 @@ public class WeatherConfiguration {
         }
 
         if (isEmpty(getPeriod())) {
-            result += "weather?" + location;
+            answer += "weather?" + location;
         } else {
-            result += "forecast/daily?" + location + "&cnt=" + getPeriod();
+            answer += "forecast/daily?" + location + "&cnt=" + getPeriod();
         }
-        result += "&units=" + units.name().toLowerCase();
+        answer += "&units=" + units.name().toLowerCase();
 
-        return result;
+        return answer;
     }
 
     private String getGeoLocation() throws Exception {
@@ -105,6 +106,6 @@ public class WeatherConfiguration {
         JsonNode latitudeNode = notNull(node.get("latitude"), "latitude");
         JsonNode longitudeNode = notNull(node.get("longitude"), "longitude");
 
-        return "lat=" + latitudeNode.toString() + "&lon=" + 
longitudeNode.toString();
+        return "lat=" + latitudeNode + "&lon=" + longitudeNode;
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/46a43b37/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherEndpoint.java
----------------------------------------------------------------------
diff --git 
a/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherEndpoint.java
 
b/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherEndpoint.java
index a23cd42..b70a4fa 100644
--- 
a/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherEndpoint.java
+++ 
b/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherEndpoint.java
@@ -27,7 +27,7 @@ import org.apache.camel.spi.UriParam;
  */
 public class WeatherEndpoint extends DefaultPollingEndpoint {
     @UriParam
-    private WeatherConfiguration configuration;
+    private final WeatherConfiguration configuration;
 
     public WeatherEndpoint(String uri, WeatherComponent component, 
WeatherConfiguration properties) {
         super(uri, component);
@@ -48,8 +48,8 @@ public class WeatherEndpoint extends DefaultPollingEndpoint {
     public Consumer createConsumer(Processor processor) throws Exception {
         WeatherConsumer answer = new WeatherConsumer(this, processor, 
this.configuration.getQuery());
 
-        // ScheduledPollConsumer default delay is 500 millis and that is too 
often for polling a feed,
-        // so we override with a new default value. End user can override this 
value by providing a consumer.delay parameter
+        // ScheduledPollConsumer default delay is 500 millis and that is too 
often for polling a feed, so we override
+        // with a new default value. End user can override this value by 
providing a consumer.delay parameter
         answer.setDelay(WeatherConsumer.DEFAULT_CONSUMER_DELAY);
         configureConsumer(answer);
         return answer;

http://git-wip-us.apache.org/repos/asf/camel/blob/46a43b37/components/camel-weather/src/test/java/org/apache/camel/component/weather/BaseWeatherConsumerTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-weather/src/test/java/org/apache/camel/component/weather/BaseWeatherConsumerTest.java
 
b/components/camel-weather/src/test/java/org/apache/camel/component/weather/BaseWeatherConsumerTest.java
index 8b8754e..07076e9 100644
--- 
a/components/camel-weather/src/test/java/org/apache/camel/component/weather/BaseWeatherConsumerTest.java
+++ 
b/components/camel-weather/src/test/java/org/apache/camel/component/weather/BaseWeatherConsumerTest.java
@@ -37,6 +37,7 @@ public abstract class BaseWeatherConsumerTest extends 
CamelTestSupport {
         assertNotNull(in);
         assertNotNull(in.getBody());
         String body = assertIsInstanceOf(String.class, in.getBody());
+        assertStringContains(body, "\"coord\":{");
         assertStringContains(body, "temp");
     }
 

Reply via email to