You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pp...@apache.org on 2020/09/08 11:33:14 UTC
[camel-quarkus] branch master updated: Weather native support fixes
#1631
This is an automated email from the ASF dual-hosted git repository.
ppalaga pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/master by this push:
new 071d76e Weather native support fixes #1631
071d76e is described below
commit 071d76e6d7bb8d7070de404c488cf0241b300197
Author: Zineb Bendhiba <be...@gmail.com>
AuthorDate: Mon Sep 7 12:30:08 2020 +0200
Weather native support fixes #1631
---
docs/modules/ROOT/pages/reference/components.adoc | 4 +-
.../ROOT/pages/reference/extensions/weather.adoc | 8 +-
docs/modules/ROOT/pages/reference/index.adoc | 4 +-
extensions-jvm/pom.xml | 1 -
.../component/weather/it/WeatherResource.java | 51 --------
extensions/pom.xml | 1 +
.../weather/deployment/pom.xml | 12 ++
.../weather/deployment/WeatherProcessor.java | 16 +--
{extensions-jvm => extensions}/weather/pom.xml | 1 -
.../weather/runtime/pom.xml | 38 +++++-
.../main/resources/META-INF/quarkus-extension.yaml | 3 +-
integration-tests/pom.xml | 1 +
.../weather}/pom.xml | 64 +++++++---
.../component/weather/it/WeatherResource.java | 134 +++++++++++++++++++++
.../src/main/resources/application.properties | 23 ++++
.../quarkus/component/weather/it/WeatherIT.java | 16 +--
.../quarkus/component/weather/it/WeatherTest.java | 106 ++++++++++++++++
tooling/scripts/test-categories.yaml | 1 +
18 files changed, 383 insertions(+), 101 deletions(-)
diff --git a/docs/modules/ROOT/pages/reference/components.adoc b/docs/modules/ROOT/pages/reference/components.adoc
index 6107dcb..281d2a0 100644
--- a/docs/modules/ROOT/pages/reference/components.adoc
+++ b/docs/modules/ROOT/pages/reference/components.adoc
@@ -832,8 +832,8 @@ Stable | 1.1.0 | Camel WebSocket support with Vert.x
| xref:reference/extensions/vm.adoc[VM] | [.camel-element-artifact]##camel-quarkus-vm## | [.camel-element-Native]##Native## +
Stable | 0.3.0 | Call another endpoint in the same CamelContext asynchronously.
-| xref:reference/extensions/weather.adoc[Weather] | [.camel-element-artifact]##camel-quarkus-weather## | [.camel-element-JVM]##JVM## +
-Preview | 1.1.0 | Poll the weather information from Open Weather Map.
+| xref:reference/extensions/weather.adoc[Weather] | [.camel-element-artifact]##camel-quarkus-weather## | [.camel-element-Native]##Native## +
+Stable | 1.1.0 | Poll the weather information from Open Weather Map.
| xref:reference/extensions/web3j.adoc[Web3j Ethereum Blockchain] | [.camel-element-artifact]##camel-quarkus-web3j## | [.camel-element-JVM]##JVM## +
Preview | 1.1.0 | Interact with Ethereum nodes using web3j client API.
diff --git a/docs/modules/ROOT/pages/reference/extensions/weather.adoc b/docs/modules/ROOT/pages/reference/extensions/weather.adoc
index 61024fc..c63560d 100644
--- a/docs/modules/ROOT/pages/reference/extensions/weather.adoc
+++ b/docs/modules/ROOT/pages/reference/extensions/weather.adoc
@@ -6,7 +6,7 @@
:page-aliases: extensions/weather.adoc
[.badges]
-[.badge-key]##Since Camel Quarkus##[.badge-version]##1.1.0## [.badge-key]##JVM##[.badge-supported]##supported## [.badge-key]##Native##[.badge-unsupported]##unsupported##
+[.badge-key]##Since Camel Quarkus##[.badge-version]##1.1.0## [.badge-key]##JVM##[.badge-supported]##supported## [.badge-key]##Native##[.badge-supported]##supported##
Poll the weather information from Open Weather Map.
@@ -27,3 +27,9 @@ Please refer to the above link for usage and configuration details.
----
Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.
+
+== SSL in native mode
+
+This extension auto-enables SSL support in native mode. Hence you do not need to add
+`quarkus.ssl.native=true` to your `application.properties` yourself. See also
+https://quarkus.io/guides/native-and-ssl[Quarkus SSL guide].
diff --git a/docs/modules/ROOT/pages/reference/index.adoc b/docs/modules/ROOT/pages/reference/index.adoc
index 50f9bb4..e800b02 100644
--- a/docs/modules/ROOT/pages/reference/index.adoc
+++ b/docs/modules/ROOT/pages/reference/index.adoc
@@ -767,8 +767,8 @@ Stable | 1.1.0 | Camel WebSocket support with Vert.x
| xref:reference/extensions/vm.adoc[VM] | camel-quarkus-vm | [.camel-element-Native]##Native## +
Stable | 0.3.0 | Call another endpoint in the same CamelContext asynchronously.
-| xref:reference/extensions/weather.adoc[Weather] | camel-quarkus-weather | [.camel-element-JVM]##JVM## +
-Preview | 1.1.0 | Poll the weather information from Open Weather Map.
+| xref:reference/extensions/weather.adoc[Weather] | camel-quarkus-weather | [.camel-element-Native]##Native## +
+Stable | 1.1.0 | Poll the weather information from Open Weather Map.
| xref:reference/extensions/web3j.adoc[Web3j Ethereum Blockchain] | camel-quarkus-web3j | [.camel-element-JVM]##JVM## +
Preview | 1.1.0 | Interact with Ethereum nodes using web3j client API.
diff --git a/extensions-jvm/pom.xml b/extensions-jvm/pom.xml
index 46e456e..26e81cb 100644
--- a/extensions-jvm/pom.xml
+++ b/extensions-jvm/pom.xml
@@ -130,7 +130,6 @@
<module>thrift</module>
<module>twilio</module>
<module>velocity</module>
- <module>weather</module>
<module>web3j</module>
<module>weka</module>
<module>wordpress</module>
diff --git a/extensions-jvm/weather/integration-test/src/main/java/org/apache/camel/quarkus/component/weather/it/WeatherResource.java b/extensions-jvm/weather/integration-test/src/main/java/org/apache/camel/quarkus/component/weather/it/WeatherResource.java
deleted file mode 100644
index 73ee3c1..0000000
--- a/extensions-jvm/weather/integration-test/src/main/java/org/apache/camel/quarkus/component/weather/it/WeatherResource.java
+++ /dev/null
@@ -1,51 +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.quarkus.component.weather.it;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.inject.Inject;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.apache.camel.CamelContext;
-import org.jboss.logging.Logger;
-
-@Path("/weather")
-@ApplicationScoped
-public class WeatherResource {
-
- private static final Logger LOG = Logger.getLogger(WeatherResource.class);
-
- private static final String COMPONENT_WEATHER = "weather";
- @Inject
- CamelContext context;
-
- @Path("/load/component/weather")
- @GET
- @Produces(MediaType.TEXT_PLAIN)
- public Response loadComponentWeather() throws Exception {
- /* This is an autogenerated test */
- if (context.getComponent(COMPONENT_WEATHER) != null) {
- return Response.ok().build();
- }
- LOG.warnf("Could not load [%s] from the Camel context", COMPONENT_WEATHER);
- return Response.status(500, COMPONENT_WEATHER + " could not be loaded from the Camel context").build();
- }
-}
diff --git a/extensions/pom.xml b/extensions/pom.xml
index e0daf61..8422ec0 100644
--- a/extensions/pom.xml
+++ b/extensions/pom.xml
@@ -180,6 +180,7 @@
<module>vertx-http</module>
<module>vertx-websocket</module>
<module>vm</module>
+ <module>weather</module>
<module>websocket-jsr356</module>
<module>xpath</module>
<module>xslt</module>
diff --git a/extensions-jvm/weather/deployment/pom.xml b/extensions/weather/deployment/pom.xml
similarity index 82%
rename from extensions-jvm/weather/deployment/pom.xml
rename to extensions/weather/deployment/pom.xml
index 62802d6..407dbf7 100644
--- a/extensions-jvm/weather/deployment/pom.xml
+++ b/extensions/weather/deployment/pom.xml
@@ -40,6 +40,18 @@
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-weather</artifactId>
</dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-jackson-deployment</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-support-commons-logging-deployment</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-support-httpclient-deployment</artifactId>
+ </dependency>
</dependencies>
<build>
diff --git a/extensions-jvm/weather/deployment/src/main/java/org/apache/camel/quarkus/component/weather/deployment/WeatherProcessor.java b/extensions/weather/deployment/src/main/java/org/apache/camel/quarkus/component/weather/deployment/WeatherProcessor.java
similarity index 68%
rename from extensions-jvm/weather/deployment/src/main/java/org/apache/camel/quarkus/component/weather/deployment/WeatherProcessor.java
rename to extensions/weather/deployment/src/main/java/org/apache/camel/quarkus/component/weather/deployment/WeatherProcessor.java
index 3192a5a..38b1c57 100644
--- a/extensions-jvm/weather/deployment/src/main/java/org/apache/camel/quarkus/component/weather/deployment/WeatherProcessor.java
+++ b/extensions/weather/deployment/src/main/java/org/apache/camel/quarkus/component/weather/deployment/WeatherProcessor.java
@@ -17,11 +17,8 @@
package org.apache.camel.quarkus.component.weather.deployment;
import io.quarkus.deployment.annotations.BuildStep;
-import io.quarkus.deployment.annotations.ExecutionTime;
-import io.quarkus.deployment.annotations.Record;
+import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem;
import io.quarkus.deployment.builditem.FeatureBuildItem;
-import io.quarkus.deployment.pkg.steps.NativeBuild;
-import org.apache.camel.quarkus.core.JvmOnlyRecorder;
import org.jboss.logging.Logger;
class WeatherProcessor {
@@ -34,13 +31,8 @@ class WeatherProcessor {
return new FeatureBuildItem(FEATURE);
}
- /**
- * Remove this once this extension starts supporting the native mode.
- */
- @BuildStep(onlyIf = NativeBuild.class)
- @Record(value = ExecutionTime.RUNTIME_INIT)
- void warnJvmInNative(JvmOnlyRecorder recorder) {
- JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
- recorder.warnJvmInNative(FEATURE); // warn at runtime
+ @BuildStep
+ ExtensionSslNativeSupportBuildItem activateSslNativeSupport() {
+ return new ExtensionSslNativeSupportBuildItem(FEATURE);
}
}
diff --git a/extensions-jvm/weather/pom.xml b/extensions/weather/pom.xml
similarity index 97%
rename from extensions-jvm/weather/pom.xml
rename to extensions/weather/pom.xml
index cb64f0c..8286d4c 100644
--- a/extensions-jvm/weather/pom.xml
+++ b/extensions/weather/pom.xml
@@ -35,6 +35,5 @@
<modules>
<module>deployment</module>
<module>runtime</module>
- <module>integration-test</module>
</modules>
</project>
diff --git a/extensions-jvm/weather/runtime/pom.xml b/extensions/weather/runtime/pom.xml
similarity index 69%
rename from extensions-jvm/weather/runtime/pom.xml
rename to extensions/weather/runtime/pom.xml
index a6bb8ff..fb5d52f 100644
--- a/extensions-jvm/weather/runtime/pom.xml
+++ b/extensions/weather/runtime/pom.xml
@@ -56,6 +56,40 @@
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-weather</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-annotations</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-jackson</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-support-commons-logging</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-support-httpclient</artifactId>
</dependency>
</dependencies>
@@ -67,7 +101,9 @@
<executions>
<execution>
<id>update-extension-doc-page</id>
- <goals><goal>update-extension-doc-page</goal></goals>
+ <goals>
+ <goal>update-extension-doc-page</goal>
+ </goals>
<phase>process-classes</phase>
</execution>
</executions>
diff --git a/extensions-jvm/weather/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/weather/runtime/src/main/resources/META-INF/quarkus-extension.yaml
similarity index 97%
rename from extensions-jvm/weather/runtime/src/main/resources/META-INF/quarkus-extension.yaml
rename to extensions/weather/runtime/src/main/resources/META-INF/quarkus-extension.yaml
index fa59fef..a33edc7 100644
--- a/extensions-jvm/weather/runtime/src/main/resources/META-INF/quarkus-extension.yaml
+++ b/extensions/weather/runtime/src/main/resources/META-INF/quarkus-extension.yaml
@@ -24,9 +24,8 @@
name: "Camel Weather"
description: "Poll the weather information from Open Weather Map"
metadata:
- unlisted: true
guide: "https://camel.apache.org/camel-quarkus/latest/reference/extensions/weather.html"
categories:
- "integration"
status:
- - "preview"
+ - "stable"
diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml
index f55637b..29c4e39 100644
--- a/integration-tests/pom.xml
+++ b/integration-tests/pom.xml
@@ -151,6 +151,7 @@
<module>validator</module>
<module>vertx</module>
<module>vertx-websocket</module>
+ <module>weather</module>
<module>websocket-jsr356</module>
<module>xml</module>
<module>xstream</module>
diff --git a/extensions-jvm/weather/integration-test/pom.xml b/integration-tests/weather/pom.xml
similarity index 59%
rename from extensions-jvm/weather/integration-test/pom.xml
rename to integration-tests/weather/pom.xml
index a70d86a..a2e9ef8 100644
--- a/extensions-jvm/weather/integration-test/pom.xml
+++ b/integration-tests/weather/pom.xml
@@ -23,25 +23,14 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-build-parent-it</artifactId>
+ <artifactId>camel-quarkus-integration-tests</artifactId>
<version>1.1.0-SNAPSHOT</version>
- <relativePath>../../../poms/build-parent-it/pom.xml</relativePath>
</parent>
- <artifactId>camel-quarkus-weather-integration-test</artifactId>
- <name>Camel Quarkus :: Weather :: Integration Test</name>
+ <artifactId>camel-quarkus-integration-test-weather</artifactId>
+ <name>Camel Quarkus :: Integration Tests :: Weather</name>
<description>Integration tests for Camel Quarkus Weather extension</description>
- <properties>
- <!-- mvnd, a.k.a. Maven Daemon: https://github.com/mvndaemon/mvnd -->
- <!-- The following rule tells mvnd to build the listed deployment modules before this module. -->
- <!-- This is important because mvnd builds modules in parallel by default. The deployment modules are not -->
- <!-- explicit dependencies of this module in the Maven sense, although they are required by the Quarkus Maven plugin. -->
- <!-- Please update the rule whenever you change the dependencies of this module by running -->
- <!-- mvn process-resources -Pformat from the root directory -->
- <mvnd.builder.rule>camel-quarkus-support-policy-deployment,camel-quarkus-weather-deployment</mvnd.builder.rule>
- </properties>
-
<dependencyManagement>
<dependencies>
<dependency>
@@ -61,7 +50,7 @@
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
- <artifactId>quarkus-resteasy</artifactId>
+ <artifactId>quarkus-resteasy-jackson</artifactId>
</dependency>
<!-- test dependencies -->
@@ -75,6 +64,21 @@
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
+
+ <!-- The following dependencies guarantee that this module is built after them. You can update them by runing `mvn process-resources -Pformat -N` from the source tree root directory -->
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-weather-deployment</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
</dependencies>
<build>
@@ -92,4 +96,34 @@
</plugin>
</plugins>
</build>
+
+ <profiles>
+ <profile>
+ <id>native</id>
+ <activation>
+ <property>
+ <name>native</name>
+ </property>
+ </activation>
+ <properties>
+ <quarkus.package.type>native</quarkus.package.type>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
</project>
diff --git a/integration-tests/weather/src/main/java/org/apache/camel/quarkus/component/weather/it/WeatherResource.java b/integration-tests/weather/src/main/java/org/apache/camel/quarkus/component/weather/it/WeatherResource.java
new file mode 100644
index 0000000..ef36307
--- /dev/null
+++ b/integration-tests/weather/src/main/java/org/apache/camel/quarkus/component/weather/it/WeatherResource.java
@@ -0,0 +1,134 @@
+/*
+ * 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.quarkus.component.weather.it;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.camel.ConsumerTemplate;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.weather.WeatherConstants;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
+import org.jboss.logging.Logger;
+
+@Path("/weather")
+@ApplicationScoped
+public class WeatherResource {
+
+ private static final Logger LOG = Logger.getLogger(WeatherResource.class);
+
+ @Inject
+ ProducerTemplate producerTemplate;
+
+ @Inject
+ ConsumerTemplate consumerTemplate;
+
+ @ConfigProperty(name = "open.weather.api-id")
+ String weatherApiId;
+
+ @Path("location/{location}")
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response getWeatherByLocation(@PathParam("location") String location) {
+ LOG.infof("Retrieve weather with location : %s", location);
+ final String response = producerTemplate.requestBodyAndHeader(
+ "weather:foo?location=random&appid=" + weatherApiId,
+ "Hello World", WeatherConstants.WEATHER_LOCATION, location, String.class);
+ LOG.infof("Got response from weather: %s", response);
+ return Response
+ .ok()
+ .entity(response)
+ .build();
+ }
+
+ @Path("lat/{lat}/lon/{lon}")
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response getWeatherByCoordinate(@PathParam("lat") String latitude, @PathParam("lon") String longitude) {
+ LOG.infof("Retrieve weather with georgraphic coordinates latitude : %s, longitude %s", latitude, longitude);
+ final String response = producerTemplate.requestBody(
+ "weather:foo?lat=" + latitude + "&lon=" + longitude + "&appid=" + weatherApiId,
+ "Hello World", String.class);
+ LOG.infof("Got response from weather: %s", response);
+ return Response
+ .ok()
+ .entity(response)
+ .build();
+ }
+
+ @Path("zip/{zip}")
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response getWeatherByZip(@PathParam("zip") String zip) {
+ LOG.infof("Retrieve weather with georgraphic coordinates zip %s", zip);
+ final String response = producerTemplate.requestBody(
+ "weather:foo?zip=" + zip + "&appid=" + weatherApiId, "Hello World", String.class);
+ LOG.infof("Got response from weather: %s", response);
+ return Response
+ .ok()
+ .entity(response)
+ .build();
+ }
+
+ @Path("ids/{ids}")
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response getWeatherByIds(@PathParam("ids") String ids) {
+ LOG.infof("Retrieve weather with georgraphic coordinates ids %s", ids);
+ final String response = producerTemplate.requestBody(
+ "weather:foo?ids=" + ids + "&appid=" + weatherApiId, "Hello World", String.class);
+ LOG.infof("Got response from weather: %s", response);
+ return Response
+ .ok()
+ .entity(response)
+ .build();
+ }
+
+ @Path("location/{location}/period/{period}")
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response getWeatherByPeriod(@PathParam("location") String location, @PathParam("period") String period) {
+ LOG.infof("Retrieve weather with location : %s and period %s", location, period);
+ final String response = producerTemplate.requestBodyAndHeader(
+ "weather:foo?location=random&appid=" + weatherApiId + "&period=" + period,
+ "Hello World", WeatherConstants.WEATHER_LOCATION, location, String.class);
+ LOG.infof("Got response from weather: %s", response);
+ return Response
+ .ok()
+ .entity(response)
+ .build();
+ }
+
+ @Path("{location}")
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response getWeather(@PathParam("location") String location) throws Exception {
+ final String message = consumerTemplate.receiveBody(
+ "weather:foo?appid=" + weatherApiId + "&location=" + location, String.class);
+ return Response
+ .ok()
+ .entity(message)
+ .build();
+ }
+
+}
diff --git a/integration-tests/weather/src/main/resources/application.properties b/integration-tests/weather/src/main/resources/application.properties
new file mode 100644
index 0000000..10f778a
--- /dev/null
+++ b/integration-tests/weather/src/main/resources/application.properties
@@ -0,0 +1,23 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+#
+# Camel :: Weather
+#
+
+# use your own API key from openweathermap.org. This key is from Apache Camel integration tests usage only
+open.weather.api-id={{env:WEATHER_APPID:9162755b2efa555823cfe0451d7fff38}}
\ No newline at end of file
diff --git a/extensions-jvm/weather/integration-test/src/test/java/org/apache/camel/quarkus/component/weather/it/WeatherTest.java b/integration-tests/weather/src/test/java/org/apache/camel/quarkus/component/weather/it/WeatherIT.java
similarity index 70%
rename from extensions-jvm/weather/integration-test/src/test/java/org/apache/camel/quarkus/component/weather/it/WeatherTest.java
rename to integration-tests/weather/src/test/java/org/apache/camel/quarkus/component/weather/it/WeatherIT.java
index e5daa32..d527e7e 100644
--- a/extensions-jvm/weather/integration-test/src/test/java/org/apache/camel/quarkus/component/weather/it/WeatherTest.java
+++ b/integration-tests/weather/src/test/java/org/apache/camel/quarkus/component/weather/it/WeatherIT.java
@@ -16,19 +16,9 @@
*/
package org.apache.camel.quarkus.component.weather.it;
-import io.quarkus.test.junit.QuarkusTest;
-import io.restassured.RestAssured;
-import org.junit.jupiter.api.Test;
+import io.quarkus.test.junit.NativeImageTest;
-@QuarkusTest
-class WeatherTest {
-
- @Test
- public void loadComponentWeather() {
- /* A simple autogenerated test */
- RestAssured.get("/weather/load/component/weather")
- .then()
- .statusCode(200);
- }
+@NativeImageTest
+class WeatherIT extends WeatherTest {
}
diff --git a/integration-tests/weather/src/test/java/org/apache/camel/quarkus/component/weather/it/WeatherTest.java b/integration-tests/weather/src/test/java/org/apache/camel/quarkus/component/weather/it/WeatherTest.java
new file mode 100644
index 0000000..f60db18
--- /dev/null
+++ b/integration-tests/weather/src/test/java/org/apache/camel/quarkus/component/weather/it/WeatherTest.java
@@ -0,0 +1,106 @@
+/*
+ * 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.quarkus.component.weather.it;
+
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasKey;
+
+@QuarkusTest
+class WeatherTest {
+
+ @Test
+ public void loadByLocationName() {
+ RestAssured.given()
+ .get("/weather/location/London,uk")
+ .then()
+ .statusCode(200)
+ .body("name", equalTo("London"))
+ .body("sys.country", equalTo("GB"))
+ .body("main", hasKey("temp"));
+ }
+
+ @Test
+ public void loadByGeographicCoordinates() {
+ RestAssured.given()
+ .get("/weather/lat/48.85/lon/2.35")
+ .then()
+ .statusCode(200)
+ .body("name", equalTo("Paris"))
+ .body("sys.country", equalTo("FR"))
+ .body("main", hasKey("temp"));
+ }
+
+ @Test
+ public void loadByZipCode() {
+ RestAssured.given()
+ .get("/weather/zip/92130,fr")
+ .then()
+ .statusCode(200)
+ .body("name", equalTo("Issy-les-Moulineaux"))
+ .body("sys.country", equalTo("FR"))
+ .body("main", hasKey("temp"));
+ }
+
+ @Test
+ public void loadByIds() {
+ RestAssured.given()
+ // ids for Cairns / Rome / Paris / London
+ .get("/weather/ids/2172797,3169070,2988507,2643743")
+ .then()
+ .statusCode(200)
+ .body("cnt", equalTo(4))
+ .body("list[0].name", equalTo("Cairns"))
+ .body("list[1].name", equalTo("Rome"))
+ .body("list[2].name", equalTo("Paris"))
+ .body("list[3].name", equalTo("London"));
+ }
+
+ @Test
+ public void loadByPeriod() {
+ RestAssured.given()
+ .get("/weather/location/London,uk/period/5")
+ .then()
+ .statusCode(200)
+ .body("cnt", equalTo(5))
+ .body("city.country", equalTo("GB"))
+ .body("city.name", equalTo("London"));
+
+ RestAssured.given()
+ .get("/weather/location/Paris,fr/period/14")
+ .then()
+ .statusCode(200)
+ .body("cnt", equalTo(14))
+ .body("city.country", equalTo("FR"))
+ .body("city.name", equalTo("Paris"));
+ }
+
+ @Test
+ public void testConsumer() {
+ RestAssured.given()
+ .get("/weather/Paris,fr")
+ .then()
+ .statusCode(200)
+ .body("name", equalTo("Paris"))
+ .body("sys.country", equalTo("FR"))
+ .body("main", hasKey("temp"));
+ }
+
+}
diff --git a/tooling/scripts/test-categories.yaml b/tooling/scripts/test-categories.yaml
index b07a6b1..c86e11f 100644
--- a/tooling/scripts/test-categories.yaml
+++ b/tooling/scripts/test-categories.yaml
@@ -72,6 +72,7 @@ xml-json-olingo4:
- dataformats-json
- dropbox
- olingo4
+ - weather
dozer-ispn-social:
- dozer
- infinispan