This is an automated email from the ASF dual-hosted git repository.
jamesnetherton pushed a commit to branch 3.33.x
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/3.33.x by this push:
new 94d9183c87 Improve HTTP proxy tests
94d9183c87 is described below
commit 94d9183c876c7a57568f79c8351201276fa868a4
Author: Lukas Lowinger <[email protected]>
AuthorDate: Tue Mar 24 16:23:08 2026 +0100
Improve HTTP proxy tests
---
.../quarkus/component/http/http/it/HttpTest.java | 23 +++++++++++++++-------
.../component/http/common/AbstractHttpTest.java | 16 +++++++++++++++
.../component/http/common/HttpTestResource.java | 11 +++++++++++
3 files changed, 43 insertions(+), 7 deletions(-)
diff --git
a/integration-test-groups/http/http/src/test/java/org/apache/camel/quarkus/component/http/http/it/HttpTest.java
b/integration-test-groups/http/http/src/test/java/org/apache/camel/quarkus/component/http/http/it/HttpTest.java
index 913faf9b24..f03f59571a 100644
---
a/integration-test-groups/http/http/src/test/java/org/apache/camel/quarkus/component/http/http/it/HttpTest.java
+++
b/integration-test-groups/http/http/src/test/java/org/apache/camel/quarkus/component/http/http/it/HttpTest.java
@@ -36,6 +36,8 @@ import org.junit.jupiter.params.provider.MethodSource;
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.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.params.provider.Arguments.arguments;
@TestCertificates(certificates = {
@@ -100,7 +102,9 @@ public class HttpTest extends AbstractHttpTest {
@ParameterizedTest
@MethodSource("proxyProviders")
- void testNonProxyRouting(String nonProxyHosts, int proxyPort, String
proxyHost, int status, String expectedBody) {
+ void testNonProxyRouting(String nonProxyHosts, int proxyPort, String
proxyHost, int status, String expectedBody,
+ boolean proxyShouldBeInvoked) {
+ int before = getProxyInvocations();
var response = RestAssured.given()
.queryParam("non-proxy-hosts", nonProxyHosts)
.queryParam("proxy-port", proxyPort)
@@ -110,9 +114,14 @@ public class HttpTest extends AbstractHttpTest {
.then()
.statusCode(status);
- // Only check the body if an expected value was provided and not null
- if (expectedBody != null) {
- response.body("metadata.groupId", is(expectedBody));
+ response.body("metadata.groupId", is(expectedBody));
+
+ int after = getProxyInvocations();
+
+ if (proxyShouldBeInvoked) {
+ assertTrue(after > before, "Proxy count should have increased.
Before: " + before + ", after: " + after);
+ } else {
+ assertEquals(after, before, "Proxy invocation count should be the
same.");
}
}
@@ -124,9 +133,9 @@ public class HttpTest extends AbstractHttpTest {
String expectedGroupId = "org.apache.camel.quarkus";
return Stream.of(
- arguments("repo.maven.apache.org", actualPort, host, 200,
expectedGroupId),
- arguments("*.apache.org", fakePort, host, 200,
expectedGroupId),
- arguments("*localhost*", fakePort, host, 500, null));
+ arguments("repo.maven.apache.org", actualPort, host, 200,
expectedGroupId, false),
+ arguments("*.apache.org", fakePort, host, 200,
expectedGroupId, false),
+ arguments("*localhost*", actualPort, host, 200,
expectedGroupId, true));
}
}
diff --git
a/integration-tests-support/http/src/test/java/org/apache/camel/quarkus/component/http/common/AbstractHttpTest.java
b/integration-tests-support/http/src/test/java/org/apache/camel/quarkus/component/http/common/AbstractHttpTest.java
index 323d4b157c..28befcb3e5 100644
---
a/integration-tests-support/http/src/test/java/org/apache/camel/quarkus/component/http/common/AbstractHttpTest.java
+++
b/integration-tests-support/http/src/test/java/org/apache/camel/quarkus/component/http/common/AbstractHttpTest.java
@@ -25,6 +25,7 @@ import static
org.apache.camel.quarkus.component.http.common.AbstractHttpResourc
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;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public abstract class AbstractHttpTest {
public abstract String component();
@@ -108,6 +109,7 @@ public abstract class AbstractHttpTest {
@Test
public void proxyServer() {
+ int before = getProxyInvocations();
RestAssured
.given()
.when()
@@ -117,9 +119,23 @@ public abstract class AbstractHttpTest {
.body(
"metadata.groupId", is("org.apache.camel.quarkus"),
"metadata.artifactId", is("camel-quarkus-" +
component()));
+ int after = getProxyInvocations();
+ assertTrue(after > before, "Proxy count should have increased. Before:
" + before + ", after: " + after);
}
protected Integer getPort(String configKey) {
return ConfigProvider.getConfig().getValue(configKey, Integer.class);
}
+
+ protected int getProxyInvocations() {
+ String proxyHost = ConfigProvider.getConfig().getValue("proxy.host",
String.class);
+ int proxyPort = getPort("proxy.port");
+ String count = RestAssured.given()
+ .baseUri("http://" + proxyHost)
+ .port(proxyPort)
+ .get("/proxy-status")
+ .then()
+ .extract().asString();
+ return Integer.parseInt(count);
+ }
}
diff --git
a/integration-tests-support/http/src/test/java/org/apache/camel/quarkus/component/http/common/HttpTestResource.java
b/integration-tests-support/http/src/test/java/org/apache/camel/quarkus/component/http/common/HttpTestResource.java
index 58d389169d..74256e58b0 100644
---
a/integration-tests-support/http/src/test/java/org/apache/camel/quarkus/component/http/common/HttpTestResource.java
+++
b/integration-tests-support/http/src/test/java/org/apache/camel/quarkus/component/http/common/HttpTestResource.java
@@ -21,6 +21,7 @@ import java.util.Map;
import java.util.Objects;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
import io.vertx.core.Handler;
@@ -44,6 +45,8 @@ public class HttpTestResource implements
QuarkusTestResourceLifecycleManager {
public static final String KEYSTORE_NAME = "localhost";
public static final String KEYSTORE_PASSWORD =
"localhost-keystore-password";
+ public static final AtomicInteger proxyInvocationCount = new
AtomicInteger(0);
+
private ProxyServer server;
@Override
@@ -115,6 +118,14 @@ public class HttpTestResource implements
QuarkusTestResourceLifecycleManager {
@Override
public void handle(HttpServerRequest httpServerRequest) {
+ // If the test asks for status, return the count
+ if (httpServerRequest.path().equals("/proxy-status")) {
+
httpServerRequest.response().end(String.valueOf(proxyInvocationCount.get()));
+ return;
+ }
+ // This only increments if the request is NOT for /proxy-status
+ proxyInvocationCount.incrementAndGet();
+
String authorization =
httpServerRequest.getHeader("Proxy-Authorization");
HttpServerResponse response = httpServerRequest.response();
if (httpServerRequest.method().equals(HttpMethod.CONNECT) &&
authorization == null) {