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 2023/07/13 16:29:38 UTC
[camel-quarkus] 01/03: [closes #3087] Divide HTTP tests into separate modules
This is an automated email from the ASF dual-hosted git repository.
ppalaga pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit 9f6b5cbdc413c458f3c20b177e9fc2a5c7f88fc1
Author: Andrej Vano <av...@redhat.com>
AuthorDate: Mon Jun 26 14:03:39 2023 +0200
[closes #3087] Divide HTTP tests into separate modules
---
integration-tests/http/common/pom.xml | 102 ++++
.../http/common/AbstractHttpResource.java | 71 +++
.../component/http/common/CommonProducers.java | 49 ++
.../component/http/common/HttpService.java} | 50 +-
.../src/main/resources/application.properties | 6 +
.../src/main/resources/jsse/keystore.p12 | Bin
.../src/main/resources/jsse/truststore.jks | Bin
.../component/http/common/AbstractHttpTest.java | 123 +++++
.../component/http/common}/HttpTestResource.java | 8 +-
integration-tests/http/http/pom.xml | 100 ++++
.../component/http/http}/HttpProducers.java | 13 +-
.../quarkus/component/http/http/HttpResource.java | 178 +++++++
.../quarkus/component/http/http/HttpRoutes.java} | 38 +-
.../quarkus/component/http}/http/it/HttpIT.java | 7 +-
.../quarkus/component/http/http/it/HttpTest.java | 88 ++++
integration-tests/http/netty-http/pom.xml | 92 ++++
.../component/http/netty/NettyHttpProducers.java} | 12 +-
.../component/http/netty/NettyHttpResource.java | 122 +++++
.../component/http/netty/NettyHttpRoutes.java | 35 ++
.../ProxyCapableClientInitializerFactory.java | 6 +-
.../component/http/netty/it/NettyHttpIT.java} | 4 +-
.../component/http/netty/it/NettyHttpTest.java | 74 +++
integration-tests/http/pom.xml | 197 +-------
.../component/http/it/GreetingServerEndpoint.java | 48 --
.../quarkus/component/http/it/HttpResource.java | 539 ---------------------
.../camel/quarkus/component/http/it/HttpRoute.java | 95 ----
.../http/src/main/resources/restcountries/cz.json | 81 ----
.../camel/quarkus/component/http/it/HttpTest.java | 288 -----------
integration-tests/http/vertx-http/pom.xml | 96 ++++
.../vertx}/VertxClientRelatedBeansProducer.java | 2 +-
.../component/http/vertx/VertxHttpService.java} | 21 +-
.../component/http/vertx/VertxResource.java | 226 +++++++++
.../quarkus/component/http/vertx/VertxRoutes.java} | 14 +-
.../src/main/resources/application.properties | 16 +-
.../component/http/vertx/it/VertxHttpIT.java} | 4 +-
.../component/http/vertx/it/VertxHttpTest.java | 113 +++++
poms/bom-test/pom.xml | 11 +
37 files changed, 1584 insertions(+), 1345 deletions(-)
diff --git a/integration-tests/http/common/pom.xml b/integration-tests/http/common/pom.xml
new file mode 100644
index 0000000000..c8cc6e8b3b
--- /dev/null
+++ b/integration-tests/http/common/pom.xml
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-integration-test-http</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-quarkus-integration-test-http-common</artifactId>
+ <name>Camel Quarkus :: Integration Tests :: HTTP :: Common</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-resteasy</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-elytron-security-properties-file</artifactId>
+ </dependency>
+
+ <!-- test dependencies -->
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-junit5</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.rest-assured</groupId>
+ <artifactId>rest-assured</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.testcontainers</groupId>
+ <artifactId>testcontainers</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-junit4-mock</artifactId>
+ </dependency>
+
+ <!-- test dependencies - camel-quarkus -->
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-integration-test-support</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.jboss.jandex</groupId>
+ <artifactId>jandex-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>make-index</id>
+ <goals>
+ <goal>jandex</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>true</skipTests>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/integration-tests/http/common/src/main/java/org/apache/camel/quarkus/component/http/common/AbstractHttpResource.java b/integration-tests/http/common/src/main/java/org/apache/camel/quarkus/component/http/common/AbstractHttpResource.java
new file mode 100644
index 0000000000..62067fa414
--- /dev/null
+++ b/integration-tests/http/common/src/main/java/org/apache/camel/quarkus/component/http/common/AbstractHttpResource.java
@@ -0,0 +1,71 @@
+/*
+ * 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.http.common;
+
+import jakarta.annotation.security.RolesAllowed;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.inject.Inject;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.QueryParam;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.Response;
+import org.apache.camel.ConsumerTemplate;
+import org.apache.camel.Exchange;
+import org.apache.camel.FluentProducerTemplate;
+
+@ApplicationScoped
+public abstract class AbstractHttpResource {
+ public static final String PROXIED_URL = "https://repo.maven.apache.org/maven2/org/apache/camel/quarkus/camel-quarkus-%s/maven-metadata.xml";
+ public static final String USER_ADMIN = "admin";
+ public static final String USER_ADMIN_PASSWORD = "adm1n";
+ public static final String USER_NO_ADMIN = "noadmin";
+ public static final String USER_NO_ADMIN_PASSWORD = "n0Adm1n";
+
+ @Inject
+ protected FluentProducerTemplate producerTemplate;
+
+ @Inject
+ protected ConsumerTemplate consumerTemplate;
+
+ @Path("/auth/basic/secured")
+ @GET
+ @RolesAllowed("admin")
+ @Produces(MediaType.TEXT_PLAIN)
+ public String basicAuth(@QueryParam("component") String component) {
+ return "Component " + component + " is using basic auth";
+ }
+
+ public abstract String httpGet(int port);
+
+ public abstract String httpPost(int port, String message);
+
+ @Path("/get-https")
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public String httpsGet() {
+ return producerTemplate
+ .to("direct:https")
+ .withHeader(Exchange.HTTP_METHOD, "GET")
+ .request(String.class);
+ }
+
+ public abstract Response basicAuth(int port, String username, String password);
+
+ public abstract String httpProxy();
+}
diff --git a/integration-tests/http/common/src/main/java/org/apache/camel/quarkus/component/http/common/CommonProducers.java b/integration-tests/http/common/src/main/java/org/apache/camel/quarkus/component/http/common/CommonProducers.java
new file mode 100644
index 0000000000..e05a911045
--- /dev/null
+++ b/integration-tests/http/common/src/main/java/org/apache/camel/quarkus/component/http/common/CommonProducers.java
@@ -0,0 +1,49 @@
+/*
+ * 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.http.common;
+
+import jakarta.inject.Named;
+import org.apache.camel.support.jsse.KeyManagersParameters;
+import org.apache.camel.support.jsse.KeyStoreParameters;
+import org.apache.camel.support.jsse.SSLContextParameters;
+import org.apache.camel.support.jsse.TrustManagersParameters;
+
+public class CommonProducers {
+
+ @Named
+ public SSLContextParameters sslContextParameters() {
+ KeyStoreParameters keystoreParameters = new KeyStoreParameters();
+ keystoreParameters.setResource("/jsse/keystore.p12");
+ keystoreParameters.setPassword("changeit");
+
+ KeyStoreParameters truststoreParameters = new KeyStoreParameters();
+ truststoreParameters.setResource("/jsse/truststore.jks");
+ truststoreParameters.setPassword("changeit");
+
+ TrustManagersParameters trustManagersParameters = new TrustManagersParameters();
+ trustManagersParameters.setKeyStore(truststoreParameters);
+ SSLContextParameters sslContextParameters = new SSLContextParameters();
+ sslContextParameters.setTrustManagers(trustManagersParameters);
+
+ KeyManagersParameters keyManagersParameters = new KeyManagersParameters();
+ keyManagersParameters.setKeyPassword("changeit");
+ keyManagersParameters.setKeyStore(keystoreParameters);
+ sslContextParameters.setKeyManagers(keyManagersParameters);
+
+ return sslContextParameters;
+ }
+}
diff --git a/integration-tests/http/src/main/java/org/apache/camel/quarkus/component/http/it/VertxClientRelatedBeansProducer.java b/integration-tests/http/common/src/main/java/org/apache/camel/quarkus/component/http/common/HttpService.java
similarity index 51%
copy from integration-tests/http/src/main/java/org/apache/camel/quarkus/component/http/it/VertxClientRelatedBeansProducer.java
copy to integration-tests/http/common/src/main/java/org/apache/camel/quarkus/component/http/common/HttpService.java
index 3f6949d0c2..1225d049dc 100644
--- a/integration-tests/http/src/main/java/org/apache/camel/quarkus/component/http/it/VertxClientRelatedBeansProducer.java
+++ b/integration-tests/http/common/src/main/java/org/apache/camel/quarkus/component/http/common/HttpService.java
@@ -14,31 +14,47 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.quarkus.component.http.it;
+package org.apache.camel.quarkus.component.http.common;
-import io.vertx.core.VertxOptions;
-import io.vertx.ext.web.client.spi.CookieStore;
import jakarta.enterprise.context.ApplicationScoped;
-import jakarta.inject.Named;
-import jakarta.inject.Singleton;
+import jakarta.ws.rs.Consumes;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.core.MediaType;
+import org.jboss.resteasy.annotations.GZIP;
+@Path("/service/common")
@ApplicationScoped
-public class VertxClientRelatedBeansProducer {
+public class HttpService {
+ @Path("/get")
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public String get() {
+ return "get";
+ }
- @Singleton
- @Produces
- @Named("myVertxOptions")
- VertxOptions createOptions() {
- // Setting an inconsistent value to generate an IllegalArgumentException on first Vertx.x HTTP client request
- return new VertxOptions().setMaxEventLoopExecuteTime(0);
+ @Path("/toUpper")
+ @POST
+ @Consumes(MediaType.TEXT_PLAIN)
+ @Produces(MediaType.TEXT_PLAIN)
+ public String toUpper(String message) {
+ return message.toUpperCase();
}
- @ApplicationScoped
- @Produces
- @Named("myVertxCookieStore")
- CookieStore createCookieStore() {
- return CookieStore.build();
+ @Path("/https")
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public String httpsGet() {
+ return "HTTPS GET";
}
+ @Path("/compress")
+ @GET
+ @GZIP
+ @Produces(MediaType.TEXT_PLAIN)
+ public String compress() {
+ return "Compressed response";
+ }
}
diff --git a/integration-tests/http/src/main/resources/application.properties b/integration-tests/http/common/src/main/resources/application.properties
similarity index 88%
copy from integration-tests/http/src/main/resources/application.properties
copy to integration-tests/http/common/src/main/resources/application.properties
index ed8496c3a9..b04a3f35fd 100644
--- a/integration-tests/http/src/main/resources/application.properties
+++ b/integration-tests/http/common/src/main/resources/application.properties
@@ -29,3 +29,9 @@ quarkus.security.users.embedded.users.admin=adm1n
quarkus.security.users.embedded.users.noadmin=n0Adm1n
quarkus.security.users.embedded.roles.admin=admin
quarkus.security.users.embedded.roles.noadmin=user
+
+quarkus.http.insecure-requests=enabled
+quarkus.http.ssl.certificate.key-store-file=jsse/keystore.p12
+quarkus.http.ssl.certificate.key-store-password=changeit
+quarkus.resteasy.gzip.enabled=true
+
diff --git a/integration-tests/http/src/main/resources/jsse/keystore.p12 b/integration-tests/http/common/src/main/resources/jsse/keystore.p12
similarity index 100%
rename from integration-tests/http/src/main/resources/jsse/keystore.p12
rename to integration-tests/http/common/src/main/resources/jsse/keystore.p12
diff --git a/integration-tests/http/src/main/resources/jsse/truststore.jks b/integration-tests/http/common/src/main/resources/jsse/truststore.jks
similarity index 100%
rename from integration-tests/http/src/main/resources/jsse/truststore.jks
rename to integration-tests/http/common/src/main/resources/jsse/truststore.jks
diff --git a/integration-tests/http/common/src/test/java/org/apache/camel/quarkus/component/http/common/AbstractHttpTest.java b/integration-tests/http/common/src/test/java/org/apache/camel/quarkus/component/http/common/AbstractHttpTest.java
new file mode 100644
index 0000000000..6d67070bad
--- /dev/null
+++ b/integration-tests/http/common/src/test/java/org/apache/camel/quarkus/component/http/common/AbstractHttpTest.java
@@ -0,0 +1,123 @@
+/*
+ * 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.http.common;
+
+import io.restassured.RestAssured;
+import org.eclipse.microprofile.config.ConfigProvider;
+import org.junit.jupiter.api.Test;
+
+import static org.apache.camel.quarkus.component.http.common.AbstractHttpResource.USER_ADMIN;
+import static org.apache.camel.quarkus.component.http.common.AbstractHttpResource.USER_ADMIN_PASSWORD;
+import static org.apache.camel.quarkus.component.http.common.AbstractHttpResource.USER_NO_ADMIN;
+import static org.apache.camel.quarkus.component.http.common.AbstractHttpResource.USER_NO_ADMIN_PASSWORD;
+import static org.hamcrest.Matchers.is;
+
+public abstract class AbstractHttpTest {
+ public abstract String component();
+
+ public abstract void compression();
+
+ @Test
+ public void basicProducerGet() {
+ RestAssured
+ .given()
+ .queryParam("test-port", RestAssured.port)
+ .when()
+ .get("/test/client/{component}/get", component())
+ .then()
+ .statusCode(200)
+ .body(is("get"));
+ }
+
+ @Test
+ public void basicProducerPost() {
+ RestAssured
+ .given()
+ .queryParam("test-port", RestAssured.port)
+ .body("message")
+ .when()
+ .post("/test/client/{component}/post", component())
+ .then()
+ .statusCode(200)
+ .body(is("MESSAGE"));
+ }
+
+ @Test
+ public void httpsProducer() {
+ RestAssured
+ .when()
+ .get("/test/client/{component}/get-https", component())
+ .then()
+ .statusCode(200)
+ .body(is("HTTPS GET"));
+ }
+
+ @Test
+ public void basicAuth() {
+ // No credentials expect 401 response
+ RestAssured
+ .given()
+ .queryParam("test-port", RestAssured.port)
+ .queryParam("component", component())
+ .when()
+ .get("/test/client/{component}/auth/basic", component())
+ .then()
+ .statusCode(401);
+
+ // Invalid credentials expect 403 response
+ RestAssured
+ .given()
+ .queryParam("test-port", RestAssured.port)
+ .queryParam("component", component())
+ .queryParam("username", USER_NO_ADMIN)
+ .queryParam("password", USER_NO_ADMIN_PASSWORD)
+ .when()
+ .get("/test/client/{component}/auth/basic", component())
+ .then()
+ .statusCode(403);
+
+ // Valid credentials expect 200 response
+ RestAssured
+ .given()
+ .queryParam("test-port", RestAssured.port)
+ .queryParam("component", component())
+ .queryParam("username", USER_ADMIN)
+ .queryParam("password", USER_ADMIN_PASSWORD)
+ .when()
+ .get("/test/client/{component}/auth/basic", component())
+ .then()
+ .statusCode(200)
+ .body(is("Component " + component() + " is using basic auth"));
+ }
+
+ @Test
+ public void proxyServer() {
+ RestAssured
+ .given()
+ .when()
+ .get("/test/client/{component}/proxy", component())
+ .then()
+ .statusCode(200)
+ .body(
+ "metadata.groupId", is("org.apache.camel.quarkus"),
+ "metadata.artifactId", is("camel-quarkus-" + component()));
+ }
+
+ protected Integer getPort(String configKey) {
+ return ConfigProvider.getConfig().getValue(configKey, Integer.class);
+ }
+}
diff --git a/integration-tests/http/src/test/java/org/apache/camel/quarkus/component/http/it/HttpTestResource.java b/integration-tests/http/common/src/test/java/org/apache/camel/quarkus/component/http/common/HttpTestResource.java
similarity index 88%
rename from integration-tests/http/src/test/java/org/apache/camel/quarkus/component/http/it/HttpTestResource.java
rename to integration-tests/http/common/src/test/java/org/apache/camel/quarkus/component/http/common/HttpTestResource.java
index 13c48282ce..ee5c47df23 100644
--- a/integration-tests/http/src/test/java/org/apache/camel/quarkus/component/http/it/HttpTestResource.java
+++ b/integration-tests/http/common/src/test/java/org/apache/camel/quarkus/component/http/common/HttpTestResource.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.quarkus.component.http.it;
+package org.apache.camel.quarkus.component.http.common;
import java.util.Map;
import java.util.Objects;
@@ -25,14 +25,14 @@ import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.utility.DockerImageName;
-import static org.apache.camel.quarkus.component.http.it.HttpResource.USER_ADMIN;
-import static org.apache.camel.quarkus.component.http.it.HttpResource.USER_ADMIN_PASSWORD;
+import static org.apache.camel.quarkus.component.http.common.AbstractHttpResource.USER_ADMIN;
+import static org.apache.camel.quarkus.component.http.common.AbstractHttpResource.USER_ADMIN_PASSWORD;
public class HttpTestResource implements QuarkusTestResourceLifecycleManager {
private static final DockerImageName TINY_PROXY_IMAGE_NAME = DockerImageName.parse("monokal/tinyproxy");
private static final Integer TINY_PROXY_PORT = 8888;
- private GenericContainer container;
+ private GenericContainer<?> container;
@Override
public Map<String, String> start() {
diff --git a/integration-tests/http/http/pom.xml b/integration-tests/http/http/pom.xml
new file mode 100644
index 0000000000..51ada75e3e
--- /dev/null
+++ b/integration-tests/http/http/pom.xml
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-integration-test-http</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-quarkus-integration-test-http-http</artifactId>
+ <name>Camel Quarkus :: Integration Tests :: HTTP :: HTTP</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-integration-test-http-common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-integration-test-http-common</artifactId>
+ <type>test-jar</type>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-resteasy-jsonb</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-http</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-direct</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-seda</artifactId>
+ </dependency>
+ </dependencies>
+ <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>
+ <profile>
+ <id>skip-testcontainers-tests</id>
+ <activation>
+ <property>
+ <name>skip-testcontainers-tests</name>
+ </property>
+ </activation>
+ <properties>
+ <skipTests>true</skipTests>
+ </properties>
+ </profile>
+ </profiles>
+</project>
diff --git a/integration-tests/http/src/main/java/org/apache/camel/quarkus/component/http/it/HttpProducers.java b/integration-tests/http/http/src/main/java/org/apache/camel/quarkus/component/http/http/HttpProducers.java
similarity index 83%
rename from integration-tests/http/src/main/java/org/apache/camel/quarkus/component/http/it/HttpProducers.java
rename to integration-tests/http/http/src/main/java/org/apache/camel/quarkus/component/http/http/HttpProducers.java
index 69cb7fc08f..4e0c8be5bd 100644
--- a/integration-tests/http/src/main/java/org/apache/camel/quarkus/component/http/it/HttpProducers.java
+++ b/integration-tests/http/http/src/main/java/org/apache/camel/quarkus/component/http/http/HttpProducers.java
@@ -14,10 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.quarkus.component.http.it;
+package org.apache.camel.quarkus.component.http.http;
import jakarta.inject.Named;
-import org.apache.camel.component.netty.ClientInitializerFactory;
import org.apache.hc.client5.http.auth.AuthScope;
import org.apache.hc.client5.http.auth.UsernamePasswordCredentials;
import org.apache.hc.client5.http.impl.auth.BasicAuthCache;
@@ -28,16 +27,10 @@ import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.eclipse.microprofile.config.ConfigProvider;
-import static org.apache.camel.quarkus.component.http.it.HttpResource.USER_ADMIN;
-import static org.apache.camel.quarkus.component.http.it.HttpResource.USER_ADMIN_PASSWORD;
+import static org.apache.camel.quarkus.component.http.common.AbstractHttpResource.USER_ADMIN;
+import static org.apache.camel.quarkus.component.http.common.AbstractHttpResource.USER_ADMIN_PASSWORD;
public class HttpProducers {
-
- @Named
- public ClientInitializerFactory proxyCapableClientInitializerFactory() {
- return new ProxyCapableClientInitializerFactory();
- }
-
@Named
HttpContext basicAuthContext() {
Integer port = ConfigProvider.getConfig().getValue("quarkus.http.test-ssl-port", Integer.class);
diff --git a/integration-tests/http/http/src/main/java/org/apache/camel/quarkus/component/http/http/HttpResource.java b/integration-tests/http/http/src/main/java/org/apache/camel/quarkus/component/http/http/HttpResource.java
new file mode 100644
index 0000000000..a72de9d50b
--- /dev/null
+++ b/integration-tests/http/http/src/main/java/org/apache/camel/quarkus/component/http/http/HttpResource.java
@@ -0,0 +1,178 @@
+/*
+ * 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.http.http;
+
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.json.Json;
+import jakarta.json.JsonObject;
+import jakarta.ws.rs.Consumes;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.QueryParam;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.Response;
+import org.apache.camel.Exchange;
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.EndpointConsumerBuilder;
+import org.apache.camel.builder.EndpointProducerBuilder;
+import org.apache.camel.builder.endpoint.EndpointRouteBuilder;
+import org.apache.camel.quarkus.component.http.common.AbstractHttpResource;
+import org.eclipse.microprofile.config.ConfigProvider;
+
+@Path("/test/client/http")
+@ApplicationScoped
+public class HttpResource extends AbstractHttpResource {
+ @Override
+ @Path("/get")
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public String httpGet(@QueryParam("test-port") int port) {
+ return producerTemplate
+ .toF("http://localhost:%d/service/common/get?bridgeEndpoint=true&connectTimeout=2000", port)
+ .withHeader(Exchange.HTTP_METHOD, "GET")
+ .request(String.class);
+ }
+
+ @Override
+ @Path("/post")
+ @POST
+ @Consumes(MediaType.TEXT_PLAIN)
+ @Produces(MediaType.TEXT_PLAIN)
+ public String httpPost(@QueryParam("test-port") int port, String message) {
+ return producerTemplate
+ .toF("http://localhost:%d/service/common/toUpper?bridgeEndpoint=true", port)
+ .withBody(message)
+ .withHeader(Exchange.CONTENT_TYPE, MediaType.TEXT_PLAIN)
+ .withHeader(Exchange.HTTP_METHOD, "POST")
+ .request(String.class);
+ }
+
+ @Override
+ @Path("/auth/basic")
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public Response basicAuth(@QueryParam("test-port") int port, @QueryParam("username") String username,
+ @QueryParam("password") String password) {
+ Exchange result = producerTemplate
+ .withHeader(Exchange.HTTP_QUERY, "component=http")
+ .toF("http://localhost:%d/test/client/http/auth/basic/secured?throwExceptionOnFailure=false"
+ + "&authMethod=BASIC"
+ + "&authUsername=%s"
+ + "&authPassword=%s", port, username, password)
+ .send();
+
+ Integer status = result.getMessage().getHeader(Exchange.HTTP_RESPONSE_CODE, Integer.class);
+ String body = result.getMessage().getBody(String.class);
+ return Response.status(status).entity(body).build();
+ }
+
+ @Path("/auth/basic/cache")
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public Response httpBasicAuthCache(@QueryParam("test-port") int port) {
+
+ Exchange result = producerTemplate
+ .withHeader(Exchange.HTTP_QUERY, "component=http")
+ .toF("http://localhost:%d/test/client/http/auth/basic/secured"
+ + "?throwExceptionOnFailure=false"
+ + "&httpContext=#basicAuthContext", port)
+ .send();
+
+ Integer status = result.getMessage().getHeader(Exchange.HTTP_RESPONSE_CODE, Integer.class);
+ String body = result.getMessage().getBody(String.class);
+ return Response.status(status).entity(body).build();
+ }
+
+ @Override
+ @Path("/proxy")
+ @GET
+ @Produces(MediaType.APPLICATION_XML)
+ public String httpProxy() {
+ Integer proxyPort = ConfigProvider.getConfig().getValue("tiny.proxy.port", Integer.class);
+ return producerTemplate
+ .toF("%s?"
+ + "proxyAuthMethod=Basic"
+ + "&proxyAuthScheme=http"
+ + "&proxyAuthHost=localhost"
+ + "&proxyAuthPort=%d"
+ + "&proxyAuthUsername=%s"
+ + "&proxyAuthPassword=%s", String.format(PROXIED_URL, "http"), proxyPort, USER_ADMIN,
+ USER_ADMIN_PASSWORD)
+ .request(String.class);
+ }
+
+ @Path("/send-dynamic")
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public String getSendDynamic(@QueryParam("test-port") int port) {
+ return producerTemplate
+ .withHeader("SendDynamicHttpEndpointPort", port)
+ .to("direct:send-dynamic")
+ .request(String.class);
+ }
+
+ @Path("/send-dynamic/service")
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public JsonObject get(@QueryParam("q") String q, @QueryParam("fq") String fq) {
+ return Json.createObjectBuilder()
+ .add("q", q)
+ .add("fq", fq)
+ .build();
+ }
+
+ @ApplicationScoped
+ RoutesBuilder sendDynamicRoutes() {
+ return new EndpointRouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ final EndpointConsumerBuilder trigger = direct(
+ "send-dynamic");
+ final EndpointProducerBuilder service = http(
+ "localhost:${header.SendDynamicHttpEndpointPort}/test/client/http/send-dynamic/service?q=*&fq=publication_date:%5B${date:now-72h"
+ + ":yyyy-MM-dd}T00:00:00Z%20TO%20${date:now-24h:yyyy-MM-dd}T23:59:59Z%5D&wt=xml&indent=false&start=0&rows=100");
+
+ from(trigger)
+ .setHeader(Exchange.HTTP_METHOD).constant("GET")
+ .toD(service)
+ .convertBodyTo(String.class);
+ }
+ };
+ }
+
+ @Path("/operation/failed/exception")
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public String operationFailedException() {
+ producerTemplate.to("direct:httpOperationFailedException").send();
+ return consumerTemplate.receiveBody("seda:dlq", 5000, String.class);
+ }
+
+ @Path("/compression")
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public String compression() {
+ return producerTemplate
+ .toF("http://localhost:%d/service/common/compress",
+ ConfigProvider.getConfig().getValue("quarkus.http.test-port", Integer.class))
+ .withHeader(Exchange.HTTP_METHOD, "GET")
+ .withHeader("Accept-Encoding", "gzip, deflate")
+ .request(String.class);
+ }
+}
diff --git a/integration-tests/http/src/main/java/org/apache/camel/quarkus/component/http/it/VertxClientRelatedBeansProducer.java b/integration-tests/http/http/src/main/java/org/apache/camel/quarkus/component/http/http/HttpRoutes.java
similarity index 50%
copy from integration-tests/http/src/main/java/org/apache/camel/quarkus/component/http/it/VertxClientRelatedBeansProducer.java
copy to integration-tests/http/http/src/main/java/org/apache/camel/quarkus/component/http/http/HttpRoutes.java
index 3f6949d0c2..9e5b41a377 100644
--- a/integration-tests/http/src/main/java/org/apache/camel/quarkus/component/http/it/VertxClientRelatedBeansProducer.java
+++ b/integration-tests/http/http/src/main/java/org/apache/camel/quarkus/component/http/http/HttpRoutes.java
@@ -14,31 +14,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.quarkus.component.http.it;
+package org.apache.camel.quarkus.component.http.http;
-import io.vertx.core.VertxOptions;
-import io.vertx.ext.web.client.spi.CookieStore;
-import jakarta.enterprise.context.ApplicationScoped;
-import jakarta.inject.Named;
-import jakarta.inject.Singleton;
-import jakarta.ws.rs.Produces;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.http.base.HttpOperationFailedException;
-@ApplicationScoped
-public class VertxClientRelatedBeansProducer {
+public class HttpRoutes extends RouteBuilder {
+ @Override
+ public void configure() throws Exception {
+ from("direct:https").to(
+ "https://localhost:{{quarkus.http.test-ssl-port}}/service/common/https?sslContextParameters=#sslContextParameters");
- @Singleton
- @Produces
- @Named("myVertxOptions")
- VertxOptions createOptions() {
- // Setting an inconsistent value to generate an IllegalArgumentException on first Vertx.x HTTP client request
- return new VertxOptions().setMaxEventLoopExecuteTime(0);
+ from("direct:httpOperationFailedException")
+ .onException(HttpOperationFailedException.class)
+ .handled(true)
+ .setBody().constant("Handled HttpOperationFailedException")
+ .to("seda:dlq")
+ .end()
+ .to("http://localhost:{{quarkus.http.test-port}}/service/common/error");
}
-
- @ApplicationScoped
- @Produces
- @Named("myVertxCookieStore")
- CookieStore createCookieStore() {
- return CookieStore.build();
- }
-
}
diff --git a/integration-tests/http/src/test/java/org/apache/camel/quarkus/component/http/it/HttpIT.java b/integration-tests/http/http/src/test/java/org/apache/camel/quarkus/component/http/http/it/HttpIT.java
similarity index 77%
copy from integration-tests/http/src/test/java/org/apache/camel/quarkus/component/http/it/HttpIT.java
copy to integration-tests/http/http/src/test/java/org/apache/camel/quarkus/component/http/http/it/HttpIT.java
index 66456156e8..467de290ff 100644
--- a/integration-tests/http/src/test/java/org/apache/camel/quarkus/component/http/it/HttpIT.java
+++ b/integration-tests/http/http/src/test/java/org/apache/camel/quarkus/component/http/http/it/HttpIT.java
@@ -14,10 +14,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.quarkus.component.http.it;
+package org.apache.camel.quarkus.component.http.http.it;
+import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.junit.QuarkusIntegrationTest;
+import org.apache.camel.quarkus.component.http.common.HttpTestResource;
@QuarkusIntegrationTest
-class HttpIT extends HttpTest {
+@QuarkusTestResource(HttpTestResource.class)
+public class HttpIT extends HttpTest {
}
diff --git a/integration-tests/http/http/src/test/java/org/apache/camel/quarkus/component/http/http/it/HttpTest.java b/integration-tests/http/http/src/test/java/org/apache/camel/quarkus/component/http/http/it/HttpTest.java
new file mode 100644
index 0000000000..e7aa79d11f
--- /dev/null
+++ b/integration-tests/http/http/src/test/java/org/apache/camel/quarkus/component/http/http/it/HttpTest.java
@@ -0,0 +1,88 @@
+/*
+ * 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.http.http.it;
+
+import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import io.restassured.http.ContentType;
+import org.apache.camel.quarkus.component.http.common.AbstractHttpTest;
+import org.apache.camel.quarkus.component.http.common.HttpTestResource;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.Matchers.empty;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
+
+@QuarkusTest
+@QuarkusTestResource(HttpTestResource.class)
+public class HttpTest extends AbstractHttpTest {
+ @Override
+ public String component() {
+ return "http";
+ }
+
+ @Test
+ public void basicAuthCache() {
+ RestAssured
+ .given()
+ .queryParam("test-port", RestAssured.port)
+ .when()
+ .get("/test/client/{component}/auth/basic/cache", component())
+ .then()
+ .statusCode(200)
+ .body(is("Component " + component() + " is using basic auth"));
+ }
+
+ @Test
+ public void sendDynamic() {
+ RestAssured
+ .given()
+ .queryParam("test-port", RestAssured.port)
+ .accept(ContentType.JSON)
+ .when()
+ .get("/test/client/{component}/send-dynamic", component())
+ .then()
+ .statusCode(200)
+ .body(
+ "q", is(not(empty())),
+ "fq", is(not(empty())));
+ }
+
+ @Test
+ public void httpOperationFailedException() {
+ RestAssured
+ .given()
+ .when()
+ .get("/test/client/{component}/operation/failed/exception", component())
+ .then()
+ .statusCode(200)
+ .body(is("Handled HttpOperationFailedException"));
+ }
+
+ @Override
+ @Test
+ public void compression() {
+ RestAssured
+ .when()
+ .get("/test/client/{component}/compression", component())
+ .then()
+ .statusCode(200)
+ .body(is("Compressed response"));
+ }
+
+}
diff --git a/integration-tests/http/netty-http/pom.xml b/integration-tests/http/netty-http/pom.xml
new file mode 100644
index 0000000000..f0333eb2d0
--- /dev/null
+++ b/integration-tests/http/netty-http/pom.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-integration-test-http</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-quarkus-integration-test-http-netty-http</artifactId>
+ <name>Camel Quarkus :: Integration Tests :: HTTP :: Netty-HTTP</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-integration-test-http-common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-integration-test-http-common</artifactId>
+ <type>test-jar</type>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-netty-http</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-direct</artifactId>
+ </dependency>
+ </dependencies>
+ <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>
+ <profile>
+ <id>skip-testcontainers-tests</id>
+ <activation>
+ <property>
+ <name>skip-testcontainers-tests</name>
+ </property>
+ </activation>
+ <properties>
+ <skipTests>true</skipTests>
+ </properties>
+ </profile>
+ </profiles>
+</project>
diff --git a/integration-tests/http/src/test/java/org/apache/camel/quarkus/component/http/it/HttpIT.java b/integration-tests/http/netty-http/src/main/java/org/apache/camel/quarkus/component/http/netty/NettyHttpProducers.java
similarity index 70%
copy from integration-tests/http/src/test/java/org/apache/camel/quarkus/component/http/it/HttpIT.java
copy to integration-tests/http/netty-http/src/main/java/org/apache/camel/quarkus/component/http/netty/NettyHttpProducers.java
index 66456156e8..c251a38363 100644
--- a/integration-tests/http/src/test/java/org/apache/camel/quarkus/component/http/it/HttpIT.java
+++ b/integration-tests/http/netty-http/src/main/java/org/apache/camel/quarkus/component/http/netty/NettyHttpProducers.java
@@ -14,10 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.quarkus.component.http.it;
+package org.apache.camel.quarkus.component.http.netty;
-import io.quarkus.test.junit.QuarkusIntegrationTest;
+import jakarta.inject.Named;
+import org.apache.camel.component.netty.ClientInitializerFactory;
-@QuarkusIntegrationTest
-class HttpIT extends HttpTest {
+public class NettyHttpProducers {
+ @Named
+ public ClientInitializerFactory proxyCapableClientInitializerFactory() {
+ return new ProxyCapableClientInitializerFactory();
+ }
}
diff --git a/integration-tests/http/netty-http/src/main/java/org/apache/camel/quarkus/component/http/netty/NettyHttpResource.java b/integration-tests/http/netty-http/src/main/java/org/apache/camel/quarkus/component/http/netty/NettyHttpResource.java
new file mode 100644
index 0000000000..bd73a38713
--- /dev/null
+++ b/integration-tests/http/netty-http/src/main/java/org/apache/camel/quarkus/component/http/netty/NettyHttpResource.java
@@ -0,0 +1,122 @@
+/*
+ * 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.http.netty;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+import java.util.zip.GZIPInputStream;
+
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.ws.rs.Consumes;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.QueryParam;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.Response;
+import org.apache.camel.Exchange;
+import org.apache.camel.quarkus.component.http.common.AbstractHttpResource;
+import org.apache.camel.util.IOHelper;
+
+@Path("/test/client/netty-http")
+@ApplicationScoped
+public class NettyHttpResource extends AbstractHttpResource {
+ @Override
+ @Path("/get")
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public String httpGet(@QueryParam("test-port") int port) {
+ return producerTemplate
+ .toF("netty-http:http://localhost:%d/service/common/get?bridgeEndpoint=true", port)
+ .withHeader(Exchange.HTTP_METHOD, "GET")
+ .request(String.class);
+ }
+
+ @Override
+ @Path("/post")
+ @POST
+ @Consumes(MediaType.TEXT_PLAIN)
+ @Produces(MediaType.TEXT_PLAIN)
+ public String httpPost(@QueryParam("test-port") int port, String message) {
+ return producerTemplate
+ .toF("netty-http:http://localhost:%d/service/common/toUpper?bridgeEndpoint=true", port)
+ .withBody(message)
+ .withHeader(Exchange.CONTENT_TYPE, MediaType.TEXT_PLAIN)
+ .withHeader(Exchange.HTTP_METHOD, "POST")
+ .request(String.class);
+ }
+
+ @Override
+ @Path("/auth/basic")
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public Response basicAuth(@QueryParam("test-port") int port, @QueryParam("username") String username,
+ @QueryParam("password") String password) {
+ String credentials = username + ":" + password;
+ String encoded = Base64.getEncoder().encodeToString(credentials.getBytes(StandardCharsets.UTF_8));
+ Exchange result = producerTemplate
+ .withHeader(Exchange.HTTP_QUERY, "component=netty-http")
+ .withHeader("Authorization", "Basic " + encoded)
+ .toF("netty-http:http://localhost:%d/test/client/netty-http/auth/basic/secured?throwExceptionOnFailure=false",
+ port)
+ .send();
+
+ Integer status = result.getMessage().getHeader(Exchange.HTTP_RESPONSE_CODE, Integer.class);
+ String body = result.getMessage().getBody(String.class);
+ return Response.status(status).entity(body).build();
+ }
+
+ @Override
+ @Path("/proxy")
+ @GET
+ @Produces(MediaType.APPLICATION_XML)
+ public String httpProxy() {
+ String url = String.format(PROXIED_URL, "netty-http");
+ return producerTemplate
+ .withHeader(Exchange.HTTP_QUERY, "component=netty-http")
+ .toF("netty-http:%s?clientInitializerFactory=#proxyCapableClientInitializerFactory", url)
+ .request(String.class);
+ }
+
+ @Path("/compression")
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public String compression(@QueryParam("test-port") int port) throws IOException {
+ byte[] compressed = producerTemplate
+ .toF("netty-http:http://localhost:%d/compressed", port)
+ .withHeader("Accept-Encoding", "gzip, deflate")
+ .request(byte[].class);
+
+ try (GZIPInputStream inputStream = new GZIPInputStream(new ByteArrayInputStream(compressed))) {
+ return IOHelper.loadText(inputStream).trim();
+ }
+ }
+
+ @Path("/serialized/exception")
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public String nettyHttpSerializedException(@QueryParam("test-port") int port) {
+ Exchange exchange = producerTemplate
+ .toF("netty-http:http://localhost:%d/test/server/serialized/exception?transferException=true", port)
+ .withHeader(Exchange.HTTP_METHOD, "GET")
+ .send();
+ return exchange.getException().getClass().getName();
+ }
+}
diff --git a/integration-tests/http/netty-http/src/main/java/org/apache/camel/quarkus/component/http/netty/NettyHttpRoutes.java b/integration-tests/http/netty-http/src/main/java/org/apache/camel/quarkus/component/http/netty/NettyHttpRoutes.java
new file mode 100644
index 0000000000..4cd8de559c
--- /dev/null
+++ b/integration-tests/http/netty-http/src/main/java/org/apache/camel/quarkus/component/http/netty/NettyHttpRoutes.java
@@ -0,0 +1,35 @@
+/*
+ * 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.http.netty;
+
+import io.quarkus.runtime.annotations.RegisterForReflection;
+import org.apache.camel.builder.RouteBuilder;
+
+@RegisterForReflection(targets = IllegalStateException.class, serialization = true)
+public class NettyHttpRoutes extends RouteBuilder {
+ @Override
+ public void configure() throws Exception {
+ from("direct:https")
+ .to("netty-http:https://localhost:{{quarkus.http.test-ssl-port}}/service/common/https?ssl=true&sslContextParameters=#sslContextParameters");
+ from("netty-http:http://0.0.0.0:{{camel.netty-http.test-port}}/test/server/hello")
+ .transform().constant("Netty Hello World");
+ from("netty-http:http://0.0.0.0:{{camel.netty-http.test-port}}/test/server/serialized/exception?transferException=true")
+ .throwException(new IllegalStateException("Forced exception"));
+ from("netty-http:http://0.0.0.0:{{camel.netty-http.compression-test-port}}/compressed?compression=true")
+ .transform().constant("Netty Hello World Compressed");
+ }
+}
diff --git a/integration-tests/http/src/main/java/org/apache/camel/quarkus/component/http/it/ProxyCapableClientInitializerFactory.java b/integration-tests/http/netty-http/src/main/java/org/apache/camel/quarkus/component/http/netty/ProxyCapableClientInitializerFactory.java
similarity index 89%
rename from integration-tests/http/src/main/java/org/apache/camel/quarkus/component/http/it/ProxyCapableClientInitializerFactory.java
rename to integration-tests/http/netty-http/src/main/java/org/apache/camel/quarkus/component/http/netty/ProxyCapableClientInitializerFactory.java
index 3243d15165..dd24d2568d 100644
--- a/integration-tests/http/src/main/java/org/apache/camel/quarkus/component/http/it/ProxyCapableClientInitializerFactory.java
+++ b/integration-tests/http/netty-http/src/main/java/org/apache/camel/quarkus/component/http/netty/ProxyCapableClientInitializerFactory.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.quarkus.component.http.it;
+package org.apache.camel.quarkus.component.http.netty;
import java.net.InetSocketAddress;
@@ -26,8 +26,8 @@ import org.apache.camel.component.netty.http.HttpClientInitializerFactory;
import org.apache.camel.component.netty.http.NettyHttpProducer;
import org.eclipse.microprofile.config.ConfigProvider;
-import static org.apache.camel.quarkus.component.http.it.HttpResource.USER_ADMIN;
-import static org.apache.camel.quarkus.component.http.it.HttpResource.USER_ADMIN_PASSWORD;
+import static org.apache.camel.quarkus.component.http.common.AbstractHttpResource.USER_ADMIN;
+import static org.apache.camel.quarkus.component.http.common.AbstractHttpResource.USER_ADMIN_PASSWORD;
public class ProxyCapableClientInitializerFactory extends HttpClientInitializerFactory {
diff --git a/integration-tests/http/src/test/java/org/apache/camel/quarkus/component/http/it/HttpIT.java b/integration-tests/http/netty-http/src/test/java/org/apache/camel/quarkus/component/http/netty/it/NettyHttpIT.java
similarity index 89%
copy from integration-tests/http/src/test/java/org/apache/camel/quarkus/component/http/it/HttpIT.java
copy to integration-tests/http/netty-http/src/test/java/org/apache/camel/quarkus/component/http/netty/it/NettyHttpIT.java
index 66456156e8..369a04472c 100644
--- a/integration-tests/http/src/test/java/org/apache/camel/quarkus/component/http/it/HttpIT.java
+++ b/integration-tests/http/netty-http/src/test/java/org/apache/camel/quarkus/component/http/netty/it/NettyHttpIT.java
@@ -14,10 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.quarkus.component.http.it;
+package org.apache.camel.quarkus.component.http.netty.it;
import io.quarkus.test.junit.QuarkusIntegrationTest;
@QuarkusIntegrationTest
-class HttpIT extends HttpTest {
+public class NettyHttpIT extends NettyHttpTest {
}
diff --git a/integration-tests/http/netty-http/src/test/java/org/apache/camel/quarkus/component/http/netty/it/NettyHttpTest.java b/integration-tests/http/netty-http/src/test/java/org/apache/camel/quarkus/component/http/netty/it/NettyHttpTest.java
new file mode 100644
index 0000000000..23946f80a9
--- /dev/null
+++ b/integration-tests/http/netty-http/src/test/java/org/apache/camel/quarkus/component/http/netty/it/NettyHttpTest.java
@@ -0,0 +1,74 @@
+/*
+ * 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.http.netty.it;
+
+import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import org.apache.camel.quarkus.component.http.common.AbstractHttpTest;
+import org.apache.camel.quarkus.component.http.common.HttpTestResource;
+import org.eclipse.microprofile.config.ConfigProvider;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.Matchers.is;
+
+@QuarkusTest
+@QuarkusTestResource(HttpTestResource.class)
+public class NettyHttpTest extends AbstractHttpTest {
+ @Override
+ public String component() {
+ return "netty-http";
+ }
+
+ @Test
+ public void basicNettyHttpServer() {
+ RestAssured
+ .given()
+ .port(ConfigProvider.getConfig().getValue("camel.netty-http.test-port", Integer.class))
+ .when()
+ .get("/test/server/hello")
+ .then()
+ .statusCode(200)
+ .body(is("Netty Hello World"));
+ }
+
+ @Test
+ public void transferException() {
+ RestAssured
+ .given()
+ .queryParam("test-port", getPort("camel.netty-http.test-port"))
+ .when()
+ .get("/test/client/{component}/serialized/exception", component())
+ .then()
+ .statusCode(200)
+ .body(is("java.lang.IllegalStateException"));
+ }
+
+ @Override
+ @Test
+ public void compression() {
+ final int port = getPort("camel.netty-http.compression-test-port");
+ RestAssured
+ .given()
+ .queryParam("test-port", port)
+ .when()
+ .get("/test/client/{component}/compression", component())
+ .then()
+ .statusCode(200)
+ .body(is("Netty Hello World Compressed"));
+ }
+}
diff --git a/integration-tests/http/pom.xml b/integration-tests/http/pom.xml
index ab2905b83b..7a075b2389 100644
--- a/integration-tests/http/pom.xml
+++ b/integration-tests/http/pom.xml
@@ -29,50 +29,7 @@
<artifactId>camel-quarkus-integration-test-http</artifactId>
<name>Camel Quarkus :: Integration Tests :: HTTP</name>
<description>Integration tests for Camel Quarkus HTTP extension</description>
-
<dependencies>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-http</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-direct</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-netty-http</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-seda</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-vertx-http</artifactId>
- </dependency>
- <dependency>
- <groupId>io.quarkus</groupId>
- <artifactId>quarkus-elytron-security-properties-file</artifactId>
- </dependency>
- <dependency>
- <groupId>io.quarkus</groupId>
- <artifactId>quarkus-websockets</artifactId>
- </dependency>
- <dependency>
- <groupId>io.quarkus</groupId>
- <artifactId>quarkus-resteasy</artifactId>
- </dependency>
- <dependency>
- <groupId>io.quarkus</groupId>
- <artifactId>quarkus-resteasy-jsonb</artifactId>
- </dependency>
- <dependency>
- <groupId>io.netty</groupId>
- <artifactId>netty-handler-proxy</artifactId>
- </dependency>
-
- <!-- test dependencies -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
@@ -83,151 +40,13 @@
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.testcontainers</groupId>
- <artifactId>testcontainers</artifactId>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>io.quarkus</groupId>
- <artifactId>quarkus-junit4-mock</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.resteasy</groupId>
- <artifactId>resteasy-multipart-provider</artifactId>
- </dependency>
-
- <!-- test dependencies - camel-quarkus -->
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-integration-test-support</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
-
-
- <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>
- <profile>
- <id>virtualDependencies</id>
- <activation>
- <property>
- <name>!noVirtualDependencies</name>
- </property>
- </activation>
- <dependencies>
- <!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory -->
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-direct-deployment</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>*</groupId>
- <artifactId>*</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-http-deployment</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>*</groupId>
- <artifactId>*</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-netty-http-deployment</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>*</groupId>
- <artifactId>*</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-seda-deployment</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>*</groupId>
- <artifactId>*</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-vertx-http-deployment</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>*</groupId>
- <artifactId>*</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- </dependencies>
- </profile>
- <profile>
- <id>skip-testcontainers-tests</id>
- <activation>
- <property>
- <name>skip-testcontainers-tests</name>
- </property>
- </activation>
- <properties>
- <skipTests>true</skipTests>
- </properties>
- </profile>
- </profiles>
-
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>common</module>
+ <module>http</module>
+ <module>netty-http</module>
+ <module>vertx-http</module>
+ </modules>
</project>
diff --git a/integration-tests/http/src/main/java/org/apache/camel/quarkus/component/http/it/GreetingServerEndpoint.java b/integration-tests/http/src/main/java/org/apache/camel/quarkus/component/http/it/GreetingServerEndpoint.java
deleted file mode 100644
index a8f2d414ad..0000000000
--- a/integration-tests/http/src/main/java/org/apache/camel/quarkus/component/http/it/GreetingServerEndpoint.java
+++ /dev/null
@@ -1,48 +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.http.it;
-
-import jakarta.websocket.OnClose;
-import jakarta.websocket.OnMessage;
-import jakarta.websocket.OnOpen;
-import jakarta.websocket.Session;
-import jakarta.websocket.server.ServerEndpoint;
-import org.jboss.logging.Logger;
-
-@ServerEndpoint("/ahc-ws/greeting")
-public class GreetingServerEndpoint {
-
- public static volatile boolean connected = false;
- private static final Logger LOG = Logger.getLogger(GreetingServerEndpoint.class);
-
- @OnOpen
- public void onOpen(Session session) {
- LOG.infof("WebSocket connection opened for session %s", session.getId());
- connected = true;
- }
-
- @OnClose
- public void onClose(Session session) {
- LOG.infof("WebSocket connection closed for session %s", session.getId());
- connected = false;
- }
-
- @OnMessage
- public void onMessage(Session session, String message) {
- session.getAsyncRemote().sendText("Hello " + message);
- }
-}
diff --git a/integration-tests/http/src/main/java/org/apache/camel/quarkus/component/http/it/HttpResource.java b/integration-tests/http/src/main/java/org/apache/camel/quarkus/component/http/it/HttpResource.java
deleted file mode 100644
index 15acdc449c..0000000000
--- a/integration-tests/http/src/main/java/org/apache/camel/quarkus/component/http/it/HttpResource.java
+++ /dev/null
@@ -1,539 +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.http.it;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.util.Base64;
-import java.util.zip.GZIPInputStream;
-
-import io.vertx.core.buffer.Buffer;
-import io.vertx.ext.web.multipart.MultipartForm;
-import jakarta.annotation.security.RolesAllowed;
-import jakarta.enterprise.context.ApplicationScoped;
-import jakarta.inject.Inject;
-import jakarta.json.Json;
-import jakarta.json.JsonObject;
-import jakarta.ws.rs.Consumes;
-import jakarta.ws.rs.GET;
-import jakarta.ws.rs.POST;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.QueryParam;
-import jakarta.ws.rs.core.MediaType;
-import jakarta.ws.rs.core.Response;
-import org.apache.camel.ConsumerTemplate;
-import org.apache.camel.Exchange;
-import org.apache.camel.FluentProducerTemplate;
-import org.apache.camel.Message;
-import org.apache.camel.PropertyBindingException;
-import org.apache.camel.ResolveEndpointFailedException;
-import org.apache.camel.RoutesBuilder;
-import org.apache.camel.builder.EndpointConsumerBuilder;
-import org.apache.camel.builder.EndpointProducerBuilder;
-import org.apache.camel.builder.endpoint.EndpointRouteBuilder;
-import org.apache.camel.http.base.HttpOperationFailedException;
-import org.apache.camel.util.IOHelper;
-import org.eclipse.microprofile.config.ConfigProvider;
-
-import static org.apache.camel.component.vertx.http.VertxHttpConstants.CONTENT_TYPE_FORM_URLENCODED;
-
-@Path("/test/client")
-@ApplicationScoped
-public class HttpResource {
-
- public static final String PROXIED_URL = "https://repo.maven.apache.org/maven2/org/apache/camel/quarkus/camel-quarkus-%s/maven-metadata.xml";
- public static final String USER_ADMIN = "admin";
- public static final String USER_ADMIN_PASSWORD = "adm1n";
- public static final String USER_NO_ADMIN = "noadmin";
- public static final String USER_NO_ADMIN_PASSWORD = "n0Adm1n";
-
- @Inject
- FluentProducerTemplate producerTemplate;
-
- @Inject
- ConsumerTemplate consumerTemplate;
-
- // *****************************
- //
- // camel-http
- //
- // *****************************
-
- @Path("/http/get")
- @GET
- @Produces(MediaType.TEXT_PLAIN)
- public String httpGet(@QueryParam("test-port") int port) {
- return producerTemplate
- .toF("http://localhost:%d/service/get?bridgeEndpoint=true&connectTimeout=2000", port)
- .withHeader(Exchange.HTTP_METHOD, "GET")
- .request(String.class);
- }
-
- @Path("/http/get-https")
- @GET
- @Produces(MediaType.TEXT_PLAIN)
- public String httpGetHttps(@QueryParam("test-port") int port) {
- return producerTemplate
- .toF("https://localhost:%d/countries/cz?bridgeEndpoint=true&sslContextParameters=#sslContextParameters", port)
- .withHeader(Exchange.HTTP_METHOD, "GET")
- .request(String.class);
- }
-
- @Path("/http/post")
- @POST
- @Consumes(MediaType.TEXT_PLAIN)
- @Produces(MediaType.TEXT_PLAIN)
- public String httpPost(@QueryParam("test-port") int port, String message) {
- return producerTemplate
- .toF("http://localhost:%d/service/toUpper?bridgeEndpoint=true", port)
- .withBody(message)
- .withHeader(Exchange.CONTENT_TYPE, MediaType.TEXT_PLAIN)
- .withHeader(Exchange.HTTP_METHOD, "POST")
- .request(String.class);
- }
-
- @Path("/http/auth/basic")
- @GET
- @Produces(MediaType.TEXT_PLAIN)
- public Response httpBasicAuth(
- @QueryParam("test-port") int port,
- @QueryParam("username") String username,
- @QueryParam("password") String password) {
-
- Exchange result = producerTemplate
- .withHeader(Exchange.HTTP_QUERY, "component=http")
- .toF("http://localhost:%d/test/client/auth/basic?throwExceptionOnFailure=false"
- + "&authMethod=BASIC"
- + "&authUsername=%s"
- + "&authPassword=%s", port, username, password)
- .send();
-
- Integer status = result.getMessage().getHeader(Exchange.HTTP_RESPONSE_CODE, Integer.class);
- String body = result.getMessage().getBody(String.class);
- return Response.status(status).entity(body).build();
- }
-
- @Path("/http/auth/basic/cache")
- @GET
- @Produces(MediaType.TEXT_PLAIN)
- public Response httpBasicAuthCache(@QueryParam("test-port") int port) {
-
- Exchange result = producerTemplate
- .withHeader(Exchange.HTTP_QUERY, "component=http")
- .toF("http://localhost:%d/test/client/auth/basic"
- + "?throwExceptionOnFailure=false"
- + "&httpContext=#basicAuthContext", port)
- .send();
-
- Integer status = result.getMessage().getHeader(Exchange.HTTP_RESPONSE_CODE, Integer.class);
- String body = result.getMessage().getBody(String.class);
- return Response.status(status).entity(body).build();
- }
-
- @Path("/http/proxy")
- @GET
- @Produces(MediaType.APPLICATION_XML)
- public String httpProxy() {
- Integer proxyPort = ConfigProvider.getConfig().getValue("tiny.proxy.port", Integer.class);
- return producerTemplate
- .toF("%s?"
- + "proxyAuthMethod=Basic"
- + "&proxyAuthScheme=http"
- + "&proxyAuthHost=localhost"
- + "&proxyAuthPort=%d"
- + "&proxyAuthUsername=%s"
- + "&proxyAuthPassword=%s", String.format(PROXIED_URL, "http"), proxyPort, USER_ADMIN,
- USER_ADMIN_PASSWORD)
- .request(String.class);
- }
-
- @Path("/http/compression")
- @GET
- @Produces(MediaType.TEXT_PLAIN)
- public String httpCompression(@QueryParam("test-port") int port) {
- return producerTemplate
- .toF("http://localhost:%d/compressed?bridgeEndpoint=true", port)
- .withHeader(Exchange.HTTP_METHOD, "GET")
- .withHeader("Accept-Encoding", "gzip, deflate")
- .request(String.class);
- }
-
- @Path("/http/operation/failed/exception")
- @GET
- @Produces(MediaType.TEXT_PLAIN)
- public String httpOperationFailedException() {
- producerTemplate.to("direct:httpOperationFailedException").send();
- return consumerTemplate.receiveBody("seda:dlq", 5000, String.class);
- }
-
- @Path("/http/serialized/exception")
- @GET
- @Produces(MediaType.TEXT_PLAIN)
- public String httpSerializedException(@QueryParam("test-port") int port) {
- Exchange exchange = producerTemplate
- .toF("http://localhost:%d/test/server/serialized/exception?bridgeEndpoint=true&transferException=true", port)
- .withHeader(Exchange.HTTP_METHOD, "GET")
- .send();
- return exchange.getException().getClass().getName();
- }
-
- // *****************************
- //
- // camel-netty-http
- //
- // *****************************
-
- @Path("/netty-http/get")
- @GET
- @Produces(MediaType.TEXT_PLAIN)
- public String nettyHttpGet(@QueryParam("test-port") int port) {
- return producerTemplate
- .toF("netty-http:http://localhost:%d/service/get?bridgeEndpoint=true", port)
- .withHeader(Exchange.HTTP_METHOD, "GET")
- .request(String.class);
- }
-
- @Path("/netty-http/get-https")
- @GET
- @Produces(MediaType.TEXT_PLAIN)
- public String nettyHttpGetHttps(@QueryParam("test-port") int port) {
- return producerTemplate
- .toF("netty-http:https://localhost:%d/countries/cz?sslContextParameters=#sslContextParameters", port)
- .withHeader(Exchange.HTTP_METHOD, "GET")
- .request(String.class);
- }
-
- @Path("/netty-http/post")
- @POST
- @Consumes(MediaType.TEXT_PLAIN)
- @Produces(MediaType.TEXT_PLAIN)
- public String nettyHttpPost(@QueryParam("test-port") int port, String message) {
- return producerTemplate
- .toF("netty-http:http://localhost:%d/service/toUpper?bridgeEndpoint=true", port)
- .withBody(message)
- .withHeader(Exchange.CONTENT_TYPE, MediaType.TEXT_PLAIN)
- .withHeader(Exchange.HTTP_METHOD, "POST")
- .request(String.class);
- }
-
- @Path("/netty-http/auth/basic")
- @GET
- @Produces(MediaType.TEXT_PLAIN)
- public Response nettyHttpBasicAuth(
- @QueryParam("test-port") int port,
- @QueryParam("username") String username,
- @QueryParam("password") String password) {
-
- String credentials = username + ":" + password;
- String encoded = Base64.getEncoder().encodeToString(credentials.getBytes(StandardCharsets.UTF_8));
- Exchange result = producerTemplate
- .withHeader(Exchange.HTTP_QUERY, "component=netty-http")
- .withHeader("Authorization", "Basic " + encoded)
- .toF("netty-http:http://localhost:%d/test/client/auth/basic?throwExceptionOnFailure=false", port)
- .send();
-
- Integer status = result.getMessage().getHeader(Exchange.HTTP_RESPONSE_CODE, Integer.class);
- String body = result.getMessage().getBody(String.class);
- return Response.status(status).entity(body).build();
- }
-
- @Path("/netty-http/proxy")
- @GET
- @Produces(MediaType.APPLICATION_XML)
- public String nettyHttpProxy() {
- String url = String.format(PROXIED_URL, "netty-http");
- return producerTemplate
- .withHeader(Exchange.HTTP_QUERY, "component=netty-http")
- .toF("netty-http:%s?clientInitializerFactory=#proxyCapableClientInitializerFactory", url)
- .request(String.class);
- }
-
- @Path("/netty-http/compression")
- @GET
- @Produces(MediaType.TEXT_PLAIN)
- public String nettyHttpCompression(@QueryParam("test-port") int port) throws IOException {
- byte[] compressed = producerTemplate
- .toF("netty-http:http://localhost:%d/compressed", port)
- .withHeader("Accept-Encoding", "gzip, deflate")
- .request(byte[].class);
-
- try (GZIPInputStream inputStream = new GZIPInputStream(new ByteArrayInputStream(compressed))) {
- return IOHelper.loadText(inputStream).trim();
- }
- }
-
- @Path("/netty-http/serialized/exception")
- @GET
- @Produces(MediaType.TEXT_PLAIN)
- public String nettyHttpSerializedException(@QueryParam("test-port") int port) {
- Exchange exchange = producerTemplate
- .toF("netty-http:http://localhost:%d/test/server/serialized/exception?transferException=true", port)
- .withHeader(Exchange.HTTP_METHOD, "GET")
- .send();
- return exchange.getException().getClass().getName();
- }
-
- // *****************************
- //
- // camel-vertx-http
- //
- // *****************************
-
- @Path("/vertx-http/get")
- @GET
- @Produces(MediaType.TEXT_PLAIN)
- public String vertxHttpGet(@QueryParam("test-port") int port) {
- return producerTemplate
- .toF("vertx-http:http://localhost:%d/service/get", port)
- .withHeader(Exchange.HTTP_METHOD, "GET")
- .request(String.class);
- }
-
- @Path("/vertx-http/get-https")
- @GET
- @Produces(MediaType.TEXT_PLAIN)
- public String vertxHttpHttps(@QueryParam("test-port") int port) {
- return producerTemplate
- .toF("vertx-http:https://localhost:%d/countries/cz?sslContextParameters=#sslContextParameters", port)
- .withHeader(Exchange.HTTP_METHOD, "GET")
- .request(String.class);
- }
-
- @Path("/vertx-http/post")
- @POST
- @Consumes(MediaType.TEXT_PLAIN)
- @Produces(MediaType.TEXT_PLAIN)
- public String vertxHttpPost(@QueryParam("test-port") int port, String message) {
- return producerTemplate
- .toF("vertx-http:http://localhost:%d/service/toUpper", port)
- .withBody(message)
- .withHeader(Exchange.CONTENT_TYPE, MediaType.TEXT_PLAIN)
- .withHeader(Exchange.HTTP_METHOD, "POST")
- .request(String.class);
- }
-
- @Path("/vertx-http/auth/basic")
- @GET
- @Produces(MediaType.TEXT_PLAIN)
- public Response vertxHttpBasicAuth(
- @QueryParam("test-port") int port,
- @QueryParam("username") String username,
- @QueryParam("password") String password) {
-
- Exchange result = producerTemplate
- .withHeader(Exchange.HTTP_QUERY, "component=vertx-http")
- .toF("vertx-http:http://localhost:%d/test/client/auth/basic?throwExceptionOnFailure=false"
- + "&basicAuthUsername=%s"
- + "&basicAuthPassword=%s", port, username, password)
- .send();
-
- Integer status = result.getMessage().getHeader(Exchange.HTTP_RESPONSE_CODE, Integer.class);
- String body = result.getMessage().getBody(String.class);
- return Response.status(status).entity(body).build();
- }
-
- @Path("/vertx-http/proxy")
- @GET
- @Produces(MediaType.APPLICATION_XML)
- public String vertxHttpProxy() {
- Integer proxyPort = ConfigProvider.getConfig().getValue("tiny.proxy.port", Integer.class);
- return producerTemplate
- .toF("vertx-http:%s?"
- + "proxyHost=localhost"
- + "&proxyPort=%d"
- + "&proxyType=HTTP"
- + "&proxyUsername=%s"
- + "&proxyPassword=%s", String.format(PROXIED_URL, "vertx-http"), proxyPort, USER_ADMIN,
- USER_ADMIN_PASSWORD)
- .request(String.class);
- }
-
- @Path("/vertx-http/compression")
- @GET
- @Produces(MediaType.TEXT_PLAIN)
- public String vertxHttpCompression(@QueryParam("test-port") int port) {
- return producerTemplate
- .toF("vertx-http:http://localhost:%d/compressed?useCompression=true", port)
- .withHeader(Exchange.HTTP_METHOD, "GET")
- .withHeader("Accept-Encoding", "gzip, deflate")
- .request(String.class);
- }
-
- @Path("/vertx-http/serialized/exception")
- @GET
- @Produces(MediaType.TEXT_PLAIN)
- public String vertxHttpSerializedException(@QueryParam("test-port") int port) {
- Exchange exchange = producerTemplate
- .toF("vertx-http:http://localhost:%d/test/server/serialized/exception?transferException=true", port)
- .withHeader(Exchange.HTTP_METHOD, "GET")
- .send();
- return exchange.getException().getClass().getName();
- }
-
- @Path("/vertx-http/multipart-form-params")
- @GET
- @Produces(MediaType.TEXT_PLAIN)
- public String vertxHttpMultipartFormParams(@QueryParam("test-port") int port,
- @QueryParam("organization") String organization,
- @QueryParam("project") String project) {
- return producerTemplate
- .toF("vertx-http:http://localhost:%d/service/multipart-form-params", port)
- .withBody("organization=" + organization + "&project=" + project)
- .withHeader(Exchange.CONTENT_TYPE, CONTENT_TYPE_FORM_URLENCODED)
- .request(String.class);
- }
-
- @Path("/vertx-http/multipart-form-data")
- @GET
- @Produces(MediaType.TEXT_PLAIN)
- public String vertxHttpMultipartFormData(@QueryParam("test-port") int port) {
-
- MultipartForm form = MultipartForm.create();
- form.binaryFileUpload("part-1", "test1.txt", Buffer.buffer("part1=content1".getBytes(StandardCharsets.UTF_8)),
- "text/plain");
- form.binaryFileUpload("part-2", "test2.xml",
- Buffer.buffer("<part2 value=\"content2\"/>".getBytes(StandardCharsets.UTF_8)), "text/xml");
-
- return producerTemplate
- .toF("vertx-http:http://localhost:%d/service/multipart-form-data", port)
- .withBody(form)
- .request(String.class);
- }
-
- @Path("/vertx-http/custom-vertx-options")
- @GET
- @Produces(MediaType.TEXT_PLAIN)
- public String vertxHttpCustomVertxOptions(@QueryParam("test-port") int port) {
- try {
- producerTemplate
- .toF("vertx-http:http://localhost:%d/service/custom-vertx-options?vertxOptions=#myVertxOptions", port)
- .request();
- return "NOT_EXPECTED: the custom vertxOptions should have triggered a ResolveEndpointFailedException";
- } catch (ResolveEndpointFailedException refex) {
- Throwable firstLevelExceptionCause = refex.getCause();
- if (firstLevelExceptionCause instanceof PropertyBindingException) {
- if (firstLevelExceptionCause.getCause() instanceof IllegalArgumentException) {
- return "OK: the custom vertxOptions has triggered the expected exception";
- }
- return "NOT_EXPECTED: the 2nd level exception cause should be of type IllegalArgumentException";
- } else {
- return "NOT_EXPECTED: the 1st level exception cause should be of type PropertyBindingException";
- }
- }
- }
-
- @Path("/vertx-http/session-management")
- @GET
- @Produces(MediaType.TEXT_PLAIN)
- public String vertxHttpSessionManagement(@QueryParam("test-port") int port) {
- String vertxHttpBaseUri = "vertx-http:http://localhost:" + port + "/service/session-management";
- Exchange result = producerTemplate
- .toF("%s/secure?sessionManagement=true&cookieStore=#myVertxCookieStore", vertxHttpBaseUri)
- .request(Exchange.class);
-
- HttpOperationFailedException exception = result.getException(HttpOperationFailedException.class);
- if (exception.getStatusCode() != 403) {
- return "NOT_EXPECTED: The first request in the session is expected to return HTTP 403";
- }
-
- result = producerTemplate
- .toF("%s/login?sessionManagement=true&cookieStore=#myVertxCookieStore", vertxHttpBaseUri)
- .withHeader("username", "my-username")
- .withHeader("password", "my-password")
- .request(Exchange.class);
-
- Message msg = result.getMessage();
- if (msg == null) {
- return "NOT_EXPECTED: The second request in the session should return a message";
- } else {
- String setCookieHeader = msg.getHeader("Set-Cookie", String.class);
- if (setCookieHeader == null || !setCookieHeader.contains("sessionId=my-session-id-123")) {
- return "NOT_EXPECTED: The message should have a Set-Cookie String header containing \"sessionId=my-session-id-123\"";
- }
- }
-
- return producerTemplate
- .toF("%s/secure?sessionManagement=true&cookieStore=#myVertxCookieStore", vertxHttpBaseUri)
- .request(String.class);
- }
-
- @Path("/vertx-http/buffer-conversion-with-charset")
- @GET
- public byte[] vertxBufferConversionWithCharset(@QueryParam("string") String string, @QueryParam("charset") String charset) {
- Buffer buffer = producerTemplate
- .to("direct:vertx-http-buffer-conversion-with-charset")
- .withBody(string)
- .withHeader(Exchange.CONTENT_TYPE, "text/plain;charset=" + charset)
- .request(Buffer.class);
-
- return buffer.getBytes();
- }
-
- // *****************************
- //
- // Send dynamic tests
- //
- // *****************************
-
- @Path("/send-dynamic")
- @GET
- @Produces(MediaType.APPLICATION_JSON)
- public String getSendDynamic(@QueryParam("test-port") int port) {
- return producerTemplate
- .withHeader("SendDynamicHttpEndpointPort", port)
- .to("direct:send-dynamic")
- .request(String.class);
- }
-
- @Path("/send-dynamic/service")
- @GET
- @Produces(MediaType.APPLICATION_JSON)
- public JsonObject get(@QueryParam("q") String q, @QueryParam("fq") String fq) {
- return Json.createObjectBuilder()
- .add("q", q)
- .add("fq", fq)
- .build();
- }
-
- @Path("/auth/basic")
- @GET
- @RolesAllowed("admin")
- @Produces(MediaType.TEXT_HTML)
- public String basicAuth(@QueryParam("component") String component) {
- return "Component " + component + " is using basic auth";
- }
-
- @ApplicationScoped
- RoutesBuilder sendDynamicRoutes() {
- return new EndpointRouteBuilder() {
- @Override
- public void configure() throws Exception {
- final EndpointConsumerBuilder trigger = direct(
- "send-dynamic");
- final EndpointProducerBuilder service = http(
- "localhost:${header.SendDynamicHttpEndpointPort}/test/client/send-dynamic/service?q=*&fq=publication_date:%5B${date:now-72h:yyyy-MM-dd}T00:00:00Z%20TO%20${date:now-24h:yyyy-MM-dd}T23:59:59Z%5D&wt=xml&indent=false&start=0&rows=100");
-
- from(trigger)
- .setHeader(Exchange.HTTP_METHOD).constant("GET")
- .toD(service)
- .convertBodyTo(String.class);
- }
- };
- }
-}
diff --git a/integration-tests/http/src/main/java/org/apache/camel/quarkus/component/http/it/HttpRoute.java b/integration-tests/http/src/main/java/org/apache/camel/quarkus/component/http/it/HttpRoute.java
deleted file mode 100644
index 755a91c94b..0000000000
--- a/integration-tests/http/src/main/java/org/apache/camel/quarkus/component/http/it/HttpRoute.java
+++ /dev/null
@@ -1,95 +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.http.it;
-
-import java.io.InputStream;
-
-import io.quarkus.runtime.annotations.RegisterForReflection;
-import io.vertx.core.buffer.Buffer;
-import jakarta.inject.Named;
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.http.base.HttpOperationFailedException;
-import org.apache.camel.support.jsse.KeyManagersParameters;
-import org.apache.camel.support.jsse.KeyStoreParameters;
-import org.apache.camel.support.jsse.SSLContextParameters;
-import org.apache.camel.support.jsse.TrustManagersParameters;
-
-@RegisterForReflection(targets = IllegalStateException.class, serialization = true)
-public class HttpRoute extends RouteBuilder {
- @Override
- public void configure() {
- from("netty-http:http://0.0.0.0:{{camel.netty-http.test-port}}/test/server/hello")
- .transform().constant("Netty Hello World");
-
- from("netty-http:http://0.0.0.0:{{camel.netty-http.test-port}}/test/server/serialized/exception?transferException=true")
- .throwException(new IllegalStateException("Forced exception"));
-
- from("netty-http:http://0.0.0.0:{{camel.netty-http.compression-test-port}}/compressed?compression=true")
- .transform().constant("Netty Hello World Compressed");
-
- from("direct:httpOperationFailedException")
- .onException(HttpOperationFailedException.class)
- .handled(true)
- .setBody().constant("Handled HttpOperationFailedException")
- .to("seda:dlq")
- .end()
- .to("http://localhost:{{camel.netty-http.test-port}}/test/server/error");
-
- from("netty-http:http://0.0.0.0:{{camel.netty-http.test-port}}/test/server/error")
- .removeHeaders("CamelHttp*")
- .setHeader(Exchange.HTTP_RESPONSE_CODE).constant(500);
-
- from("netty-http:http://0.0.0.0:{{camel.netty-http.https-test-port}}/countries/cz?ssl=true&sslContextParameters=#sslContextParameters")
- .process(new Processor() {
- @Override
- public void process(Exchange exchange) throws Exception {
- try (InputStream stream = HttpRoute.class.getResourceAsStream("/restcountries/cz.json")) {
- String json = exchange.getContext().getTypeConverter().convertTo(String.class, stream);
- exchange.getMessage().setBody(json);
- }
- }
- });
-
- from("direct:vertx-http-buffer-conversion-with-charset")
- .convertBodyTo(Buffer.class);
- }
-
- @Named
- public SSLContextParameters sslContextParameters() {
- KeyStoreParameters keystoreParameters = new KeyStoreParameters();
- keystoreParameters.setResource("/jsse/keystore.p12");
- keystoreParameters.setPassword("changeit");
-
- KeyStoreParameters truststoreParameters = new KeyStoreParameters();
- truststoreParameters.setResource("/jsse/truststore.jks");
- truststoreParameters.setPassword("changeit");
-
- TrustManagersParameters trustManagersParameters = new TrustManagersParameters();
- trustManagersParameters.setKeyStore(truststoreParameters);
- SSLContextParameters sslContextParameters = new SSLContextParameters();
- sslContextParameters.setTrustManagers(trustManagersParameters);
-
- KeyManagersParameters keyManagersParameters = new KeyManagersParameters();
- keyManagersParameters.setKeyPassword("changeit");
- keyManagersParameters.setKeyStore(keystoreParameters);
- sslContextParameters.setKeyManagers(keyManagersParameters);
-
- return sslContextParameters;
- }
-}
diff --git a/integration-tests/http/src/main/resources/restcountries/cz.json b/integration-tests/http/src/main/resources/restcountries/cz.json
deleted file mode 100644
index 87701b1356..0000000000
--- a/integration-tests/http/src/main/resources/restcountries/cz.json
+++ /dev/null
@@ -1,81 +0,0 @@
-{
- "name": "Czech Republic",
- "topLevelDomain": [
- ".cz"
- ],
- "alpha2Code": "CZ",
- "alpha3Code": "CZE",
- "callingCodes": [
- "420"
- ],
- "capital": "Prague",
- "altSpellings": [
- "CZ",
- "Česká republika",
- "Česko"
- ],
- "region": "Europe",
- "subregion": "Eastern Europe",
- "population": 10558524,
- "latlng": [
- 49.75,
- 15.5
- ],
- "demonym": "Czech",
- "area": 78865.0,
- "gini": 26.0,
- "timezones": [
- "UTC+01:00"
- ],
- "borders": [
- "AUT",
- "DEU",
- "POL",
- "SVK"
- ],
- "nativeName": "Česká republika",
- "numericCode": "203",
- "currencies": [
- {
- "code": "CZK",
- "name": "Czech koruna",
- "symbol": "Kč"
- }
- ],
- "languages": [
- {
- "iso639_1": "cs",
- "iso639_2": "ces",
- "name": "Czech",
- "nativeName": "čeština"
- },
- {
- "iso639_1": "sk",
- "iso639_2": "slk",
- "name": "Slovak",
- "nativeName": "slovenčina"
- }
- ],
- "translations": {
- "de": "Tschechische Republik",
- "es": "República Checa",
- "fr": "République tchèque",
- "ja": "チェコ",
- "it": "Repubblica Ceca",
- "br": "República Tcheca",
- "pt": "República Checa",
- "nl": "Tsjechië",
- "hr": "Češka",
- "fa": "جمهوری چک"
- },
- "flag": "https://restcountries.eu/data/cze.svg",
- "regionalBlocs": [
- {
- "acronym": "EU",
- "name": "European Union",
- "otherAcronyms": [],
- "otherNames": []
- }
- ],
- "cioc": "CZE"
-}
diff --git a/integration-tests/http/src/test/java/org/apache/camel/quarkus/component/http/it/HttpTest.java b/integration-tests/http/src/test/java/org/apache/camel/quarkus/component/http/it/HttpTest.java
deleted file mode 100644
index 2ea591ce1e..0000000000
--- a/integration-tests/http/src/test/java/org/apache/camel/quarkus/component/http/it/HttpTest.java
+++ /dev/null
@@ -1,288 +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.http.it;
-
-import io.quarkus.test.common.QuarkusTestResource;
-import io.quarkus.test.junit.QuarkusTest;
-import io.restassured.RestAssured;
-import io.restassured.http.ContentType;
-import org.eclipse.microprofile.config.ConfigProvider;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.MethodSource;
-
-import static org.apache.camel.quarkus.component.http.it.HttpResource.USER_ADMIN;
-import static org.apache.camel.quarkus.component.http.it.HttpResource.USER_ADMIN_PASSWORD;
-import static org.apache.camel.quarkus.component.http.it.HttpResource.USER_NO_ADMIN;
-import static org.apache.camel.quarkus.component.http.it.HttpResource.USER_NO_ADMIN_PASSWORD;
-import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.empty;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.not;
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
-
-@QuarkusTest
-@QuarkusTestResource(HttpTestResource.class)
-class HttpTest {
-
- private static final String[] HTTP_COMPONENTS = new String[] { "http", "netty-http", "vertx-http" };
-
- @ParameterizedTest
- @MethodSource("getHttpComponentNames")
- public void basicProducer(String component) {
- RestAssured
- .given()
- .queryParam("test-port", RestAssured.port)
- .when()
- .get("/test/client/{component}/get", component)
- .then()
- .statusCode(200)
- .body(is("get"));
-
- RestAssured
- .given()
- .queryParam("test-port", RestAssured.port)
- .body("message")
- .when()
- .post("/test/client/{component}/post", component)
- .then()
- .statusCode(200)
- .body(is("MESSAGE"));
- }
-
- @ParameterizedTest
- @MethodSource("getHttpComponentNames")
- public void httpsProducer(String component) {
- final int port = getPort("camel.netty-http.https-test-port");
- RestAssured
- .given()
- .queryParam("test-port", port)
- .when()
- .get("/test/client/{component}/get-https", component)
- .then()
- .statusCode(200)
- .body(containsString("Czech Republic"));
- }
-
- @ParameterizedTest
- @MethodSource("getHttpComponentNames")
- public void basicAuth(String component) {
- // No credentials expect 401 response
- RestAssured
- .given()
- .queryParam("test-port", RestAssured.port)
- .queryParam("component", component)
- .when()
- .get("/test/client/{component}/auth/basic", component)
- .then()
- .statusCode(401);
-
- // Invalid credentials expect 403 response
- RestAssured
- .given()
- .queryParam("test-port", RestAssured.port)
- .queryParam("component", component)
- .queryParam("username", USER_NO_ADMIN)
- .queryParam("password", USER_NO_ADMIN_PASSWORD)
- .when()
- .get("/test/client/{component}/auth/basic", component)
- .then()
- .statusCode(403);
-
- // Valid credentials expect 200 response
- RestAssured
- .given()
- .queryParam("test-port", RestAssured.port)
- .queryParam("component", component)
- .queryParam("username", USER_ADMIN)
- .queryParam("password", USER_ADMIN_PASSWORD)
- .when()
- .get("/test/client/{component}/auth/basic", component)
- .then()
- .statusCode(200)
- .body(is("Component " + component + " is using basic auth"));
- }
-
- @Test
- public void basicAuthCache() {
- RestAssured
- .given()
- .queryParam("test-port", RestAssured.port)
- .when()
- .get("/test/client/http/auth/basic/cache")
- .then()
- .statusCode(200)
- .body(is("Component http is using basic auth"));
- }
-
- @ParameterizedTest
- @MethodSource("getHttpComponentNames")
- public void proxyServer(String component) {
- RestAssured
- .given()
- .when()
- .get("/test/client/{component}/proxy", component)
- .then()
- .statusCode(200)
- .body(
- "metadata.groupId", is("org.apache.camel.quarkus"),
- "metadata.artifactId", is("camel-quarkus-" + component));
- }
-
- @ParameterizedTest
- @MethodSource("getHttpComponentNames")
- public void compression(String component) {
- final int port = getPort("camel.netty-http.compression-test-port");
- RestAssured
- .given()
- .queryParam("test-port", port)
- .when()
- .get("/test/client/{component}/compression", component)
- .then()
- .statusCode(200)
- .body(is("Netty Hello World Compressed"));
- }
-
- @ParameterizedTest
- @MethodSource("getHttpComponentNames")
- public void transferException(String component) {
- RestAssured
- .given()
- .queryParam("test-port", getPort())
- .when()
- .get("/test/client/{component}/serialized/exception", component)
- .then()
- .statusCode(200)
- .body(is("java.lang.IllegalStateException"));
- }
-
- @Test
- public void basicNettyHttpServer() {
- RestAssured
- .given()
- .port(getPort())
- .when()
- .get("/test/server/hello")
- .then()
- .statusCode(200)
- .body(is("Netty Hello World"));
- }
-
- @Test
- public void sendDynamic() {
- RestAssured
- .given()
- .queryParam("test-port", RestAssured.port)
- .accept(ContentType.JSON)
- .when()
- .get("/test/client/send-dynamic")
- .then()
- .statusCode(200)
- .body(
- "q", is(not(empty())),
- "fq", is(not(empty())));
- }
-
- @Test
- public void httpOperationFailedException() {
- RestAssured
- .given()
- .when()
- .get("/test/client/http/operation/failed/exception")
- .then()
- .statusCode(200)
- .body(is("Handled HttpOperationFailedException"));
- }
-
- @Test
- public void vertxHttpMultipartFormParamsShouldSucceed() {
- RestAssured
- .given()
- .queryParam("test-port", RestAssured.port)
- .queryParam("organization", "Apache")
- .queryParam("project", "Camel")
- .when()
- .get("/test/client/vertx-http/multipart-form-params")
- .then()
- .statusCode(200)
- .body(is("multipartFormParams(Apache, Camel)"));
- }
-
- @Test
- public void vertxHttpMultipartFormDataShouldSucceed() {
- RestAssured
- .given()
- .queryParam("test-port", RestAssured.port)
- .when()
- .get("/test/client/vertx-http/multipart-form-data")
- .then()
- .statusCode(200)
- .body(is("multipartFormData(part1=content1, <part2 value=\"content2\"/>)"));
- }
-
- @Test
- public void vertxHttpCustomVertxOptionsShouldSucceed() {
- RestAssured
- .given()
- .queryParam("test-port", RestAssured.port)
- .when()
- .get("/test/client/vertx-http/custom-vertx-options")
- .then()
- .statusCode(200)
- .body(is("OK: the custom vertxOptions has triggered the expected exception"));
- }
-
- @Test
- public void vertxHttpSessionManagementShouldReturnSecretContent() {
- RestAssured
- .given()
- .queryParam("test-port", RestAssured.port)
- .when()
- .get("/test/client/vertx-http/session-management")
- .then()
- .statusCode(200)
- .body(is("Some secret content"));
- }
-
- @Test
- public void vertxHttpBufferConversionWithCharset() {
- byte[] actualBytes = RestAssured
- .given()
- .queryParam("string", "special char €")
- .queryParam("charset", "iso-8859-15")
- .when()
- .get("/test/client/vertx-http/buffer-conversion-with-charset")
- .then()
- .statusCode(200)
- .extract().asByteArray();
-
- byte[] expectedBytes = new byte[] { 115, 112, 101, 99, 105, 97, 108, 32, 99, 104, 97, 114, 32, -92 };
- assertArrayEquals(expectedBytes, actualBytes);
- }
-
- private Integer getPort() {
- return getPort("camel.netty-http.test-port");
- }
-
- private Integer getPort(String configKey) {
- return ConfigProvider.getConfig().getValue(configKey, Integer.class);
- }
-
- private static String[] getHttpComponentNames() {
- return HTTP_COMPONENTS;
- }
-}
diff --git a/integration-tests/http/vertx-http/pom.xml b/integration-tests/http/vertx-http/pom.xml
new file mode 100644
index 0000000000..01fe562f5b
--- /dev/null
+++ b/integration-tests/http/vertx-http/pom.xml
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-integration-test-http</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-quarkus-integration-test-http-vertx-http</artifactId>
+ <name>Camel Quarkus :: Integration Tests :: HTTP :: Vertx-HTTP</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-integration-test-http-common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-integration-test-http-common</artifactId>
+ <type>test-jar</type>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-vertx-http</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-direct</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-multipart-provider</artifactId>
+ </dependency>
+ </dependencies>
+ <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>
+ <profile>
+ <id>skip-testcontainers-tests</id>
+ <activation>
+ <property>
+ <name>skip-testcontainers-tests</name>
+ </property>
+ </activation>
+ <properties>
+ <skipTests>true</skipTests>
+ </properties>
+ </profile>
+ </profiles>
+</project>
diff --git a/integration-tests/http/src/main/java/org/apache/camel/quarkus/component/http/it/VertxClientRelatedBeansProducer.java b/integration-tests/http/vertx-http/src/main/java/org/apache/camel/quarkus/component/http/vertx/VertxClientRelatedBeansProducer.java
similarity index 96%
rename from integration-tests/http/src/main/java/org/apache/camel/quarkus/component/http/it/VertxClientRelatedBeansProducer.java
rename to integration-tests/http/vertx-http/src/main/java/org/apache/camel/quarkus/component/http/vertx/VertxClientRelatedBeansProducer.java
index 3f6949d0c2..befe6d763c 100644
--- a/integration-tests/http/src/main/java/org/apache/camel/quarkus/component/http/it/VertxClientRelatedBeansProducer.java
+++ b/integration-tests/http/vertx-http/src/main/java/org/apache/camel/quarkus/component/http/vertx/VertxClientRelatedBeansProducer.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.quarkus.component.http.it;
+package org.apache.camel.quarkus.component.http.vertx;
import io.vertx.core.VertxOptions;
import io.vertx.ext.web.client.spi.CookieStore;
diff --git a/integration-tests/http/src/main/java/org/apache/camel/quarkus/component/http/it/HttpService.java b/integration-tests/http/vertx-http/src/main/java/org/apache/camel/quarkus/component/http/vertx/VertxHttpService.java
similarity index 86%
rename from integration-tests/http/src/main/java/org/apache/camel/quarkus/component/http/it/HttpService.java
rename to integration-tests/http/vertx-http/src/main/java/org/apache/camel/quarkus/component/http/vertx/VertxHttpService.java
index c341b4768e..a16feaff16 100644
--- a/integration-tests/http/src/main/java/org/apache/camel/quarkus/component/http/it/HttpService.java
+++ b/integration-tests/http/vertx-http/src/main/java/org/apache/camel/quarkus/component/http/vertx/VertxHttpService.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.quarkus.component.http.it;
+package org.apache.camel.quarkus.component.http.vertx;
import java.util.Map;
@@ -34,22 +34,7 @@ import jakarta.ws.rs.core.Response;
@Path("/service")
@ApplicationScoped
-public class HttpService {
- @Path("/get")
- @GET
- @Produces(MediaType.TEXT_PLAIN)
- public String get() {
- return "get";
- }
-
- @Path("/toUpper")
- @POST
- @Consumes(MediaType.TEXT_PLAIN)
- @Produces(MediaType.TEXT_PLAIN)
- public String toUpper(String message) {
- return message.toUpperCase();
- }
-
+public class VertxHttpService {
@POST
@Path("/multipart-form-params")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@@ -63,7 +48,7 @@ public class HttpService {
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.TEXT_PLAIN)
public String multipartFormData(Map<String, String> parts) {
- if (parts.size() != 2 || !parts.keySet().contains("part-1") || !parts.keySet().contains("part-2")) {
+ if (parts.size() != 2 || !parts.containsKey("part-1") || !parts.containsKey("part-2")) {
throw new IllegalArgumentException(
"There should be exactly 2 parts named \"part-1\" and \"parts-2\" in the multipart upload");
}
diff --git a/integration-tests/http/vertx-http/src/main/java/org/apache/camel/quarkus/component/http/vertx/VertxResource.java b/integration-tests/http/vertx-http/src/main/java/org/apache/camel/quarkus/component/http/vertx/VertxResource.java
new file mode 100644
index 0000000000..984af4ae72
--- /dev/null
+++ b/integration-tests/http/vertx-http/src/main/java/org/apache/camel/quarkus/component/http/vertx/VertxResource.java
@@ -0,0 +1,226 @@
+/*
+ * 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.http.vertx;
+
+import java.nio.charset.StandardCharsets;
+
+import io.vertx.core.buffer.Buffer;
+import io.vertx.ext.web.multipart.MultipartForm;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.ws.rs.Consumes;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.QueryParam;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.Response;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.PropertyBindingException;
+import org.apache.camel.ResolveEndpointFailedException;
+import org.apache.camel.http.base.HttpOperationFailedException;
+import org.apache.camel.quarkus.component.http.common.AbstractHttpResource;
+import org.eclipse.microprofile.config.ConfigProvider;
+
+import static org.apache.camel.component.vertx.http.VertxHttpConstants.CONTENT_TYPE_FORM_URLENCODED;
+
+@Path("/test/client/vertx-http")
+@ApplicationScoped
+public class VertxResource extends AbstractHttpResource {
+
+ @Override
+ @Path("/get")
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public String httpGet(@QueryParam("test-port") int port) {
+ return producerTemplate
+ .toF("vertx-http:http://localhost:%d/service/common/get", port)
+ .withHeader(Exchange.HTTP_METHOD, "GET")
+ .request(String.class);
+ }
+
+ @Override
+ @Path("/post")
+ @POST
+ @Consumes(MediaType.TEXT_PLAIN)
+ @Produces(MediaType.TEXT_PLAIN)
+ public String httpPost(@QueryParam("test-port") int port, String message) {
+ return producerTemplate
+ .toF("vertx-http:http://localhost:%d/service/common/toUpper", port)
+ .withBody(message)
+ .withHeader(Exchange.CONTENT_TYPE, MediaType.TEXT_PLAIN)
+ .withHeader(Exchange.HTTP_METHOD, "POST")
+ .request(String.class);
+ }
+
+ @Override
+ @Path("/auth/basic")
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public Response basicAuth(@QueryParam("test-port") int port, @QueryParam("username") String username,
+ @QueryParam("password") String password) {
+ Exchange result = producerTemplate
+ .withHeader(Exchange.HTTP_QUERY, "component=vertx-http")
+ .toF("vertx-http:http://localhost:%d/test/client/vertx-http/auth/basic/secured?throwExceptionOnFailure=false"
+ + "&basicAuthUsername=%s"
+ + "&basicAuthPassword=%s", port, username, password)
+ .send();
+
+ Integer status = result.getMessage().getHeader(Exchange.HTTP_RESPONSE_CODE, Integer.class);
+ String body = result.getMessage().getBody(String.class);
+ return Response.status(status).entity(body).build();
+ }
+
+ @Override
+ @Path("/proxy")
+ @GET
+ @Produces(MediaType.APPLICATION_XML)
+ public String httpProxy() {
+ Integer proxyPort = ConfigProvider.getConfig().getValue("tiny.proxy.port", Integer.class);
+ return producerTemplate
+ .toF("vertx-http:%s?"
+ + "proxyHost=localhost"
+ + "&proxyPort=%d"
+ + "&proxyType=HTTP"
+ + "&proxyUsername=%s"
+ + "&proxyPassword=%s", String.format(PROXIED_URL, "vertx-http"), proxyPort, USER_ADMIN,
+ USER_ADMIN_PASSWORD)
+ .request(String.class);
+ }
+
+ @Path("/compression")
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public String compression() {
+ return producerTemplate
+ .toF("vertx-http:http://localhost:%d/service/common/compress?useCompression=true",
+ ConfigProvider.getConfig().getValue("quarkus.http.test-port", Integer.class))
+ .withHeader(Exchange.HTTP_METHOD, "GET")
+ .withHeader("Accept-Encoding", "gzip, deflate")
+ .request(String.class);
+ }
+
+ @Path("/serialized/exception")
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public String vertxHttpSerializedException(@QueryParam("test-port") int port) {
+ Exchange exchange = producerTemplate
+ .toF("vertx-http:http://localhost:%d/test/server/serialized/exception?transferException=true", port)
+ .withHeader(Exchange.HTTP_METHOD, "GET")
+ .send();
+ return exchange.getException().getClass().getName();
+ }
+
+ @Path("/multipart-form-params")
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public String vertxHttpMultipartFormParams(@QueryParam("test-port") int port,
+ @QueryParam("organization") String organization,
+ @QueryParam("project") String project) {
+ return producerTemplate
+ .toF("vertx-http:http://localhost:%d/service/multipart-form-params", port)
+ .withBody("organization=" + organization + "&project=" + project)
+ .withHeader(Exchange.CONTENT_TYPE, CONTENT_TYPE_FORM_URLENCODED)
+ .request(String.class);
+ }
+
+ @Path("/multipart-form-data")
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public String vertxHttpMultipartFormData(@QueryParam("test-port") int port) {
+ MultipartForm form = MultipartForm.create();
+ form.binaryFileUpload("part-1", "test1.txt", Buffer.buffer("part1=content1".getBytes(StandardCharsets.UTF_8)),
+ "text/plain");
+ form.binaryFileUpload("part-2", "test2.xml",
+ Buffer.buffer("<part2 value=\"content2\"/>".getBytes(StandardCharsets.UTF_8)), "text/xml");
+
+ return producerTemplate
+ .toF("vertx-http:http://localhost:%d/service/multipart-form-data", port)
+ .withBody(form)
+ .request(String.class);
+ }
+
+ @Path("/custom-vertx-options")
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public String vertxHttpCustomVertxOptions(@QueryParam("test-port") int port) {
+ try {
+ producerTemplate
+ .toF("vertx-http:http://localhost:%d/service/custom-vertx-options?vertxOptions=#myVertxOptions", port)
+ .request();
+ return "NOT_EXPECTED: the custom vertxOptions should have triggered a ResolveEndpointFailedException";
+ } catch (ResolveEndpointFailedException refex) {
+ Throwable firstLevelExceptionCause = refex.getCause();
+ if (firstLevelExceptionCause instanceof PropertyBindingException) {
+ if (firstLevelExceptionCause.getCause() instanceof IllegalArgumentException) {
+ return "OK: the custom vertxOptions has triggered the expected exception";
+ }
+ return "NOT_EXPECTED: the 2nd level exception cause should be of type IllegalArgumentException";
+ } else {
+ return "NOT_EXPECTED: the 1st level exception cause should be of type PropertyBindingException";
+ }
+ }
+ }
+
+ @Path("/session-management")
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public String vertxHttpSessionManagement(@QueryParam("test-port") int port) {
+ String vertxHttpBaseUri = "vertx-http:http://localhost:" + port + "/service/session-management";
+ Exchange result = producerTemplate
+ .toF("%s/secure?sessionManagement=true&cookieStore=#myVertxCookieStore", vertxHttpBaseUri)
+ .request(Exchange.class);
+
+ HttpOperationFailedException exception = result.getException(HttpOperationFailedException.class);
+ if (exception.getStatusCode() != 403) {
+ return "NOT_EXPECTED: The first request in the session is expected to return HTTP 403";
+ }
+
+ result = producerTemplate
+ .toF("%s/login?sessionManagement=true&cookieStore=#myVertxCookieStore", vertxHttpBaseUri)
+ .withHeader("username", "my-username")
+ .withHeader("password", "my-password")
+ .request(Exchange.class);
+
+ Message msg = result.getMessage();
+ if (msg == null) {
+ return "NOT_EXPECTED: The second request in the session should return a message";
+ } else {
+ String setCookieHeader = msg.getHeader("Set-Cookie", String.class);
+ if (setCookieHeader == null || !setCookieHeader.contains("sessionId=my-session-id-123")) {
+ return "NOT_EXPECTED: The message should have a Set-Cookie String header containing \"sessionId=my-session-id-123\"";
+ }
+ }
+
+ return producerTemplate
+ .toF("%s/secure?sessionManagement=true&cookieStore=#myVertxCookieStore", vertxHttpBaseUri)
+ .request(String.class);
+ }
+
+ @Path("/buffer-conversion-with-charset")
+ @GET
+ public byte[] vertxBufferConversionWithCharset(@QueryParam("string") String string, @QueryParam("charset") String charset) {
+ Buffer buffer = producerTemplate
+ .to("direct:vertx-http-buffer-conversion-with-charset")
+ .withBody(string)
+ .withHeader(Exchange.CONTENT_TYPE, "text/plain;charset=" + charset)
+ .request(Buffer.class);
+
+ return buffer.getBytes();
+ }
+}
diff --git a/integration-tests/http/src/test/java/org/apache/camel/quarkus/component/http/it/HttpIT.java b/integration-tests/http/vertx-http/src/main/java/org/apache/camel/quarkus/component/http/vertx/VertxRoutes.java
similarity index 60%
copy from integration-tests/http/src/test/java/org/apache/camel/quarkus/component/http/it/HttpIT.java
copy to integration-tests/http/vertx-http/src/main/java/org/apache/camel/quarkus/component/http/vertx/VertxRoutes.java
index 66456156e8..bd245e830e 100644
--- a/integration-tests/http/src/test/java/org/apache/camel/quarkus/component/http/it/HttpIT.java
+++ b/integration-tests/http/vertx-http/src/main/java/org/apache/camel/quarkus/component/http/vertx/VertxRoutes.java
@@ -14,10 +14,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.quarkus.component.http.it;
+package org.apache.camel.quarkus.component.http.vertx;
-import io.quarkus.test.junit.QuarkusIntegrationTest;
+import io.vertx.core.buffer.Buffer;
+import org.apache.camel.builder.RouteBuilder;
-@QuarkusIntegrationTest
-class HttpIT extends HttpTest {
+public class VertxRoutes extends RouteBuilder {
+ @Override
+ public void configure() throws Exception {
+ from("direct:https").to(
+ "vertx-http:https://localhost:{{quarkus.http.test-ssl-port}}/service/common/https?sslContextParameters=#sslContextParameters");
+ from("direct:vertx-http-buffer-conversion-with-charset").convertBodyTo(Buffer.class);
+ }
}
diff --git a/integration-tests/http/src/main/resources/application.properties b/integration-tests/http/vertx-http/src/main/resources/application.properties
similarity index 65%
rename from integration-tests/http/src/main/resources/application.properties
rename to integration-tests/http/vertx-http/src/main/resources/application.properties
index ed8496c3a9..b4cf99252f 100644
--- a/integration-tests/http/src/main/resources/application.properties
+++ b/integration-tests/http/vertx-http/src/main/resources/application.properties
@@ -14,18 +14,4 @@
## See the License for the specific language governing permissions and
## limitations under the License.
## ---------------------------------------------------------------------------
-
-#
-# Quarkus
-#
-quarkus.native.resources.includes = jsse/*,restcountries/*
-quarkus.native.add-all-charsets = true
-quarkus.camel.native.reflection.serialization-enabled = true
-
-# Basic authentication configuration
-quarkus.security.users.embedded.enabled=true
-quarkus.security.users.embedded.plain-text=true
-quarkus.security.users.embedded.users.admin=adm1n
-quarkus.security.users.embedded.users.noadmin=n0Adm1n
-quarkus.security.users.embedded.roles.admin=admin
-quarkus.security.users.embedded.roles.noadmin=user
+quarkus.native.additional-build-args=--enable-url-protocols=https
diff --git a/integration-tests/http/src/test/java/org/apache/camel/quarkus/component/http/it/HttpIT.java b/integration-tests/http/vertx-http/src/test/java/org/apache/camel/quarkus/component/http/vertx/it/VertxHttpIT.java
similarity index 89%
rename from integration-tests/http/src/test/java/org/apache/camel/quarkus/component/http/it/HttpIT.java
rename to integration-tests/http/vertx-http/src/test/java/org/apache/camel/quarkus/component/http/vertx/it/VertxHttpIT.java
index 66456156e8..9c4a461a1a 100644
--- a/integration-tests/http/src/test/java/org/apache/camel/quarkus/component/http/it/HttpIT.java
+++ b/integration-tests/http/vertx-http/src/test/java/org/apache/camel/quarkus/component/http/vertx/it/VertxHttpIT.java
@@ -14,10 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.quarkus.component.http.it;
+package org.apache.camel.quarkus.component.http.vertx.it;
import io.quarkus.test.junit.QuarkusIntegrationTest;
@QuarkusIntegrationTest
-class HttpIT extends HttpTest {
+public class VertxHttpIT extends VertxHttpTest {
}
diff --git a/integration-tests/http/vertx-http/src/test/java/org/apache/camel/quarkus/component/http/vertx/it/VertxHttpTest.java b/integration-tests/http/vertx-http/src/test/java/org/apache/camel/quarkus/component/http/vertx/it/VertxHttpTest.java
new file mode 100644
index 0000000000..18a6c43687
--- /dev/null
+++ b/integration-tests/http/vertx-http/src/test/java/org/apache/camel/quarkus/component/http/vertx/it/VertxHttpTest.java
@@ -0,0 +1,113 @@
+/*
+ * 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.http.vertx.it;
+
+import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import org.apache.camel.quarkus.component.http.common.AbstractHttpTest;
+import org.apache.camel.quarkus.component.http.common.HttpTestResource;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.Matchers.is;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+
+@QuarkusTest
+@QuarkusTestResource(HttpTestResource.class)
+public class VertxHttpTest extends AbstractHttpTest {
+ @Override
+ public String component() {
+ return "vertx-http";
+ }
+
+ @Test
+ public void vertxHttpMultipartFormParamsShouldSucceed() {
+ RestAssured
+ .given()
+ .queryParam("test-port", RestAssured.port)
+ .queryParam("organization", "Apache")
+ .queryParam("project", "Camel")
+ .when()
+ .get("/test/client/{component}/multipart-form-params", component())
+ .then()
+ .statusCode(200)
+ .body(is("multipartFormParams(Apache, Camel)"));
+ }
+
+ @Test
+ public void vertxHttpMultipartFormDataShouldSucceed() {
+ RestAssured
+ .given()
+ .queryParam("test-port", RestAssured.port)
+ .when()
+ .get("/test/client/vertx-http/multipart-form-data")
+ .then()
+ .statusCode(200)
+ .body(is("multipartFormData(part1=content1, <part2 value=\"content2\"/>)"));
+ }
+
+ @Test
+ public void vertxHttpCustomVertxOptionsShouldSucceed() {
+ RestAssured
+ .given()
+ .queryParam("test-port", RestAssured.port)
+ .when()
+ .get("/test/client/vertx-http/custom-vertx-options")
+ .then()
+ .statusCode(200)
+ .body(is("OK: the custom vertxOptions has triggered the expected exception"));
+ }
+
+ @Test
+ public void vertxHttpSessionManagementShouldReturnSecretContent() {
+ RestAssured
+ .given()
+ .queryParam("test-port", RestAssured.port)
+ .when()
+ .get("/test/client/vertx-http/session-management")
+ .then()
+ .statusCode(200)
+ .body(is("Some secret content"));
+ }
+
+ @Test
+ public void vertxHttpBufferConversionWithCharset() {
+ byte[] actualBytes = RestAssured
+ .given()
+ .queryParam("string", "special char €")
+ .queryParam("charset", "iso-8859-15")
+ .when()
+ .get("/test/client/vertx-http/buffer-conversion-with-charset")
+ .then()
+ .statusCode(200)
+ .extract().asByteArray();
+
+ byte[] expectedBytes = new byte[] { 115, 112, 101, 99, 105, 97, 108, 32, 99, 104, 97, 114, 32, -92 };
+ assertArrayEquals(expectedBytes, actualBytes);
+ }
+
+ @Override
+ @Test
+ public void compression() {
+ RestAssured
+ .when()
+ .get("/test/client/{component}/compression", component())
+ .then()
+ .statusCode(200)
+ .body(is("Compressed response"));
+ }
+}
diff --git a/poms/bom-test/pom.xml b/poms/bom-test/pom.xml
index 99c5cb73a4..f9756117c3 100644
--- a/poms/bom-test/pom.xml
+++ b/poms/bom-test/pom.xml
@@ -217,6 +217,17 @@
<version>${camel-quarkus.version}</version>
<type>test-jar</type>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-integration-test-http-common</artifactId>
+ <version>${camel-quarkus.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-integration-test-http-common</artifactId>
+ <version>${camel-quarkus.version}</version>
+ <type>test-jar</type>
+ </dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-test-messaging-jms</artifactId>