This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 86671f0f7c33 CAMEL-23431: Migrate platform-http tests from
AvailablePortFinder to port-0 binding (#23131)
86671f0f7c33 is described below
commit 86671f0f7c339ffab5b9f3bbc66751fb6466c02b
Author: Guillaume Nodet <[email protected]>
AuthorDate: Tue May 12 09:42:32 2026 +0200
CAMEL-23431: Migrate platform-http tests from AvailablePortFinder to port-0
binding (#23131)
Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
---
.../client/OpenApiValidatorIntegrationTest.java | 24 ++++++-------
.../platform/http/main/MainHttpServer.java | 2 +-
.../http/main/MainHttpServerRouteTest.java | 12 +++----
...mHttpRestOpenApiConsumerRestDslBindingTest.java | 14 +++-----
...RestOpenApiConsumerRestDslRouteMetricsTest.java | 10 ++----
...PlatformHttpRestOpenApiConsumerRestDslTest.java | 42 ++++++++++------------
.../vertx/PlatformHttpRestOpenApiConsumerTest.java | 38 +++++++++-----------
.../VertxClientResponseCodeValidationTest.java | 10 ++----
...ertxInvalidJSonClientRequestValidationTest.java | 10 ++----
...rtxInvalidJSonClientResponseValidationTest.java | 10 ++----
.../http/vertx/VertxPlatformEventNotifierTest.java | 14 +++-----
.../http/vertx/VertxPlatformHttpBasicTest.java | 13 +++----
.../http/vertx/VertxPlatformHttpEngineTest.java | 16 ++++++++-
...rtxPlatformHttpEngineWithTypeConverterTest.java | 14 +++-----
.../vertx/VertxPlatformHttpFileResponseTest.java | 14 +++-----
.../http/vertx/VertxPlatformHttpJacksonTest.java | 10 ++----
...VertxPlatformHttpLargeMessageStreamingTest.java | 10 ++----
.../http/vertx/VertxPlatformHttpStreamingTest.java | 38 +++++++++-----------
.../VertxPlatformServerRequestValidationTest.java | 14 +++-----
19 files changed, 117 insertions(+), 198 deletions(-)
diff --git
a/components/camel-openapi-validator/src/test/java/org/apache/camel/component/rest/openapi/validator/client/OpenApiValidatorIntegrationTest.java
b/components/camel-openapi-validator/src/test/java/org/apache/camel/component/rest/openapi/validator/client/OpenApiValidatorIntegrationTest.java
index 4b9de374074d..cb6794b7fa08 100644
---
a/components/camel-openapi-validator/src/test/java/org/apache/camel/component/rest/openapi/validator/client/OpenApiValidatorIntegrationTest.java
+++
b/components/camel-openapi-validator/src/test/java/org/apache/camel/component/rest/openapi/validator/client/OpenApiValidatorIntegrationTest.java
@@ -21,9 +21,7 @@ import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.platform.http.vertx.VertxPlatformHttpServer;
import
org.apache.camel.component.platform.http.vertx.VertxPlatformHttpServerConfiguration;
import org.apache.camel.impl.DefaultCamelContext;
-import org.apache.camel.test.AvailablePortFinder;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.RegisterExtension;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.containsString;
@@ -35,9 +33,6 @@ import static org.hamcrest.Matchers.containsString;
*/
public class OpenApiValidatorIntegrationTest {
- @RegisterExtension
- AvailablePortFinder.Port port = AvailablePortFinder.find();
-
@Test
public void testValidRequestSucceeds() throws Exception {
CamelContext context = createCamelContext();
@@ -54,7 +49,7 @@ public class OpenApiValidatorIntegrationTest {
});
context.start();
- given().port(port.getPort())
+ given().port(server.getPort())
.contentType("application/json")
.body("{\"name\": \"tiger\", \"photoUrls\":
[\"img.jpg\"]}")
.when()
@@ -82,7 +77,7 @@ public class OpenApiValidatorIntegrationTest {
});
context.start();
- given().port(port.getPort())
+ given().port(server.getPort())
.contentType("application/json")
.when()
.put("/api/v3/pet")
@@ -110,7 +105,7 @@ public class OpenApiValidatorIntegrationTest {
});
context.start();
- given().port(port.getPort())
+ given().port(server.getPort())
.contentType("application/json")
.body("{\"name\": \"tiger\"}")
.when()
@@ -139,7 +134,7 @@ public class OpenApiValidatorIntegrationTest {
});
context.start();
- given().port(port.getPort())
+ given().port(server.getPort())
.when()
.get("/api/v3/pet/findByStatus")
.then()
@@ -166,7 +161,7 @@ public class OpenApiValidatorIntegrationTest {
});
context.start();
- given().port(port.getPort())
+ given().port(server.getPort())
.when()
.get("/api/v3/pet/findByTags")
.then()
@@ -198,7 +193,7 @@ public class OpenApiValidatorIntegrationTest {
// Body missing required "photoUrls" field, but the validation
level for
// schema.required is downgraded to INFO, so the request passes.
- given().port(port.getPort())
+ given().port(server.getPort())
.contentType("application/json")
.body("{\"name\": \"tiger\"}")
.when()
@@ -210,11 +205,14 @@ public class OpenApiValidatorIntegrationTest {
}
}
+ private VertxPlatformHttpServer server;
+
private CamelContext createCamelContext() throws Exception {
VertxPlatformHttpServerConfiguration conf = new
VertxPlatformHttpServerConfiguration();
- conf.setBindPort(port.getPort());
+ conf.setBindPort(0);
+ server = new VertxPlatformHttpServer(conf);
CamelContext context = new DefaultCamelContext();
- context.addService(new VertxPlatformHttpServer(conf));
+ context.addService(server);
return context;
}
}
diff --git
a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java
b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java
index 787a16c65387..03d022ac07ce 100644
---
a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java
+++
b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java
@@ -131,7 +131,7 @@ public class MainHttpServer extends ServiceSupport
implements CamelContextAware,
@ManagedAttribute(description = "HTTP server port number")
public int getPort() {
- return configuration.getBindPort();
+ return server != null ? server.getPort() : configuration.getBindPort();
}
public void setPort(int port) {
diff --git
a/components/camel-platform-http-main/src/test/java/org/apache/camel/component/platform/http/main/MainHttpServerRouteTest.java
b/components/camel-platform-http-main/src/test/java/org/apache/camel/component/platform/http/main/MainHttpServerRouteTest.java
index 7e351f5174d6..a43eeab52463 100644
---
a/components/camel-platform-http-main/src/test/java/org/apache/camel/component/platform/http/main/MainHttpServerRouteTest.java
+++
b/components/camel-platform-http-main/src/test/java/org/apache/camel/component/platform/http/main/MainHttpServerRouteTest.java
@@ -24,20 +24,16 @@ import java.net.http.HttpResponse;
import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
-import org.apache.camel.test.AvailablePortFinder;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.RegisterExtension;
import static org.junit.jupiter.api.Assertions.assertEquals;
class MainHttpServerRouteTest {
- @RegisterExtension
- static AvailablePortFinder.Port port = AvailablePortFinder.find();
-
private static CamelContext camelContext;
+ private static MainHttpServer httpServer;
@BeforeAll
static void setUp() throws Exception {
@@ -53,8 +49,8 @@ class MainHttpServerRouteTest {
// MainHttpServer needs to get registered/started explicitly
// https://issues.apache.org/jira/browse/CAMEL-21741
- MainHttpServer httpServer = new MainHttpServer();
- httpServer.setPort(port.getPort());
+ httpServer = new MainHttpServer();
+ httpServer.setPort(0);
camelContext.addService(httpServer);
camelContext.start();
@@ -71,7 +67,7 @@ class MainHttpServerRouteTest {
public void routeStatusOk() throws Exception {
HttpRequest request = HttpRequest.newBuilder()
- .uri(URI.create("http://localhost:" + port.getPort() +
"/hello"))
+ .uri(URI.create("http://localhost:" + httpServer.getPort() +
"/hello"))
.build();
HttpResponse<String> response = HttpClient.newBuilder().build()
diff --git
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/PlatformHttpRestOpenApiConsumerRestDslBindingTest.java
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/PlatformHttpRestOpenApiConsumerRestDslBindingTest.java
index 9830a4b4d302..a4170680f08a 100644
---
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/PlatformHttpRestOpenApiConsumerRestDslBindingTest.java
+++
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/PlatformHttpRestOpenApiConsumerRestDslBindingTest.java
@@ -20,21 +20,15 @@ import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.platform.http.vertx.model.Pet;
import org.apache.camel.model.rest.RestBindingMode;
-import org.apache.camel.test.AvailablePortFinder;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.RegisterExtension;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
public class PlatformHttpRestOpenApiConsumerRestDslBindingTest {
-
- @RegisterExtension
- AvailablePortFinder.Port port = AvailablePortFinder.find();
-
@Test
public void testRestOpenApiOutType() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
try {
context.addRoutes(new RouteBuilder() {
@@ -56,7 +50,7 @@ public class
PlatformHttpRestOpenApiConsumerRestDslBindingTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
given()
.when()
@@ -72,7 +66,7 @@ public class
PlatformHttpRestOpenApiConsumerRestDslBindingTest {
@Test
public void testRestOpenApiInType() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
try {
context.addRoutes(new RouteBuilder() {
@@ -92,7 +86,7 @@ public class
PlatformHttpRestOpenApiConsumerRestDslBindingTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
given()
.when()
diff --git
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/PlatformHttpRestOpenApiConsumerRestDslRouteMetricsTest.java
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/PlatformHttpRestOpenApiConsumerRestDslRouteMetricsTest.java
index 8f362cd030dd..52bba7ef7c45 100644
---
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/PlatformHttpRestOpenApiConsumerRestDslRouteMetricsTest.java
+++
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/PlatformHttpRestOpenApiConsumerRestDslRouteMetricsTest.java
@@ -20,10 +20,8 @@ import org.apache.camel.CamelContext;
import org.apache.camel.api.management.ManagedCamelContext;
import org.apache.camel.api.management.mbean.ManagedRouteMBean;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.AvailablePortFinder;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.RegisterExtension;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
@@ -31,13 +29,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
public class PlatformHttpRestOpenApiConsumerRestDslRouteMetricsTest {
-
- @RegisterExtension
- AvailablePortFinder.Port port = AvailablePortFinder.find();
-
@Test
public void testRouteMetrics() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
try {
context.addRoutes(new RouteBuilder() {
@@ -59,7 +53,7 @@ public class
PlatformHttpRestOpenApiConsumerRestDslRouteMetricsTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
ManagedRouteMBean mr
=
context.getCamelContextExtension().getContextPlugin(ManagedCamelContext.class).getManagedRoute("myRest");
diff --git
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/PlatformHttpRestOpenApiConsumerRestDslTest.java
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/PlatformHttpRestOpenApiConsumerRestDslTest.java
index 38d65dc79e45..6af6ad31f5af 100644
---
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/PlatformHttpRestOpenApiConsumerRestDslTest.java
+++
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/PlatformHttpRestOpenApiConsumerRestDslTest.java
@@ -20,10 +20,8 @@ import java.io.FileInputStream;
import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.AvailablePortFinder;
import org.apache.camel.util.IOHelper;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.RegisterExtension;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
@@ -32,13 +30,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
public class PlatformHttpRestOpenApiConsumerRestDslTest {
-
- @RegisterExtension
- AvailablePortFinder.Port port = AvailablePortFinder.find();
-
@Test
public void testRestOpenApi() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
try {
context.addRoutes(new RouteBuilder() {
@@ -54,7 +48,7 @@ public class PlatformHttpRestOpenApiConsumerRestDslTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
given()
.when()
@@ -70,7 +64,7 @@ public class PlatformHttpRestOpenApiConsumerRestDslTest {
@Test
public void testRestOpenApiDevMode() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
// run in developer mode
context.getCamelContextExtension().setProfile("dev");
@@ -85,7 +79,7 @@ public class PlatformHttpRestOpenApiConsumerRestDslTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
given()
.when()
@@ -100,7 +94,7 @@ public class PlatformHttpRestOpenApiConsumerRestDslTest {
@Test
public void testRestOpenApiMock() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
try {
context.addRoutes(new RouteBuilder() {
@@ -113,7 +107,7 @@ public class PlatformHttpRestOpenApiConsumerRestDslTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
given()
.when()
@@ -136,7 +130,7 @@ public class PlatformHttpRestOpenApiConsumerRestDslTest {
@Test
public void testRestOpenApiMissingOperation() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
try {
assertThrows(Exception.class, () -> {
@@ -150,7 +144,7 @@ public class PlatformHttpRestOpenApiConsumerRestDslTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
}, "OpenAPI specification has 18 unmapped operations to
corresponding routes");
} finally {
context.stop();
@@ -159,7 +153,7 @@ public class PlatformHttpRestOpenApiConsumerRestDslTest {
@Test
public void testRestOpenApiNotFound() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
try {
context.addRoutes(new RouteBuilder() {
@@ -172,7 +166,7 @@ public class PlatformHttpRestOpenApiConsumerRestDslTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
given()
.when()
@@ -186,7 +180,7 @@ public class PlatformHttpRestOpenApiConsumerRestDslTest {
@Test
public void testRestOpenApiNotAllowed() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
try {
context.addRoutes(new RouteBuilder() {
@@ -199,7 +193,7 @@ public class PlatformHttpRestOpenApiConsumerRestDslTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
given()
.when()
@@ -213,7 +207,7 @@ public class PlatformHttpRestOpenApiConsumerRestDslTest {
@Test
public void testRestOpenApiValidate() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
try {
context.addRoutes(new RouteBuilder() {
@@ -226,7 +220,7 @@ public class PlatformHttpRestOpenApiConsumerRestDslTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
given()
.when().contentType("application/json")
@@ -240,7 +234,7 @@ public class PlatformHttpRestOpenApiConsumerRestDslTest {
@Test
public void testRestOpenApiMockData() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
try {
context.addRoutes(new RouteBuilder() {
@@ -250,7 +244,7 @@ public class PlatformHttpRestOpenApiConsumerRestDslTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
given()
.when()
@@ -270,7 +264,7 @@ public class PlatformHttpRestOpenApiConsumerRestDslTest {
@Test
public void testRestOpenApiContextPath() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
try {
context.addRoutes(new RouteBuilder() {
@@ -286,7 +280,7 @@ public class PlatformHttpRestOpenApiConsumerRestDslTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
given()
.when()
diff --git
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/PlatformHttpRestOpenApiConsumerTest.java
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/PlatformHttpRestOpenApiConsumerTest.java
index a4403f2b8a05..d4fda8c408ec 100644
---
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/PlatformHttpRestOpenApiConsumerTest.java
+++
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/PlatformHttpRestOpenApiConsumerTest.java
@@ -19,9 +19,7 @@ package org.apache.camel.component.platform.http.vertx;
import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.AvailablePortFinder;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.RegisterExtension;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
@@ -29,13 +27,9 @@ import static
org.hamcrest.Matchers.equalToCompressingWhiteSpace;
import static org.junit.jupiter.api.Assertions.assertThrows;
public class PlatformHttpRestOpenApiConsumerTest {
-
- @RegisterExtension
- AvailablePortFinder.Port port = AvailablePortFinder.find();
-
@Test
public void testRestOpenApi() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
try {
context.addRoutes(new RouteBuilder() {
@@ -49,7 +43,7 @@ public class PlatformHttpRestOpenApiConsumerTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
MockEndpoint mock = context.getEndpoint("mock:result",
MockEndpoint.class);
mock.expectedMessageCount(1);
@@ -70,7 +64,7 @@ public class PlatformHttpRestOpenApiConsumerTest {
@Test
public void testRestOpenApiDevMode() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
// run in developer mode
context.getCamelContextExtension().setProfile("dev");
@@ -86,7 +80,7 @@ public class PlatformHttpRestOpenApiConsumerTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
given()
.when()
@@ -101,7 +95,7 @@ public class PlatformHttpRestOpenApiConsumerTest {
@Test
public void testRestOpenApiMock() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
try {
context.addRoutes(new RouteBuilder() {
@@ -115,7 +109,7 @@ public class PlatformHttpRestOpenApiConsumerTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
given()
.when()
@@ -138,7 +132,7 @@ public class PlatformHttpRestOpenApiConsumerTest {
@Test
public void testRestOpenApiMissingOperation() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
try {
assertThrows(Exception.class, () -> {
@@ -153,7 +147,7 @@ public class PlatformHttpRestOpenApiConsumerTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
}, "OpenAPI specification has 18 unmapped operations to
corresponding routes");
} finally {
context.stop();
@@ -162,7 +156,7 @@ public class PlatformHttpRestOpenApiConsumerTest {
@Test
public void testRestOpenApiNotFound() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
try {
context.addRoutes(new RouteBuilder() {
@@ -176,7 +170,7 @@ public class PlatformHttpRestOpenApiConsumerTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
given()
.when()
@@ -190,7 +184,7 @@ public class PlatformHttpRestOpenApiConsumerTest {
@Test
public void testRestOpenApiNotAllowed() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
try {
context.addRoutes(new RouteBuilder() {
@@ -204,7 +198,7 @@ public class PlatformHttpRestOpenApiConsumerTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
given()
.when()
@@ -218,7 +212,7 @@ public class PlatformHttpRestOpenApiConsumerTest {
@Test
public void testRestOpenApiValidate() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
try {
context.addRoutes(new RouteBuilder() {
@@ -232,7 +226,7 @@ public class PlatformHttpRestOpenApiConsumerTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
given()
.when()
@@ -247,7 +241,7 @@ public class PlatformHttpRestOpenApiConsumerTest {
@Test
public void testRestOpenApiMockData() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
try {
context.addRoutes(new RouteBuilder() {
@@ -258,7 +252,7 @@ public class PlatformHttpRestOpenApiConsumerTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
given()
.when()
diff --git
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxClientResponseCodeValidationTest.java
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxClientResponseCodeValidationTest.java
index 587c1dc000f9..f01735590066 100644
---
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxClientResponseCodeValidationTest.java
+++
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxClientResponseCodeValidationTest.java
@@ -20,21 +20,15 @@ import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.model.rest.RestBindingMode;
-import org.apache.camel.test.AvailablePortFinder;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.RegisterExtension;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
public class VertxClientResponseCodeValidationTest {
-
- @RegisterExtension
- AvailablePortFinder.Port port = AvailablePortFinder.find();
-
@Test
public void testInvalidResponseCode() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
try {
context.addRoutes(new RouteBuilder() {
@@ -62,7 +56,7 @@ public class VertxClientResponseCodeValidationTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
given()
.when()
diff --git
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxInvalidJSonClientRequestValidationTest.java
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxInvalidJSonClientRequestValidationTest.java
index 5ce94b5d1a9a..b1df146e9a61 100644
---
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxInvalidJSonClientRequestValidationTest.java
+++
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxInvalidJSonClientRequestValidationTest.java
@@ -19,21 +19,15 @@ package org.apache.camel.component.platform.http.vertx;
import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.model.rest.RestBindingMode;
-import org.apache.camel.test.AvailablePortFinder;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.RegisterExtension;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
public class VertxInvalidJSonClientRequestValidationTest {
-
- @RegisterExtension
- AvailablePortFinder.Port port = AvailablePortFinder.find();
-
@Test
public void testInvalidJSon() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
try {
context.addRoutes(new RouteBuilder() {
@@ -52,7 +46,7 @@ public class VertxInvalidJSonClientRequestValidationTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
given()
.when()
diff --git
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxInvalidJSonClientResponseValidationTest.java
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxInvalidJSonClientResponseValidationTest.java
index 37e0abb96df0..bbd97dc528dd 100644
---
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxInvalidJSonClientResponseValidationTest.java
+++
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxInvalidJSonClientResponseValidationTest.java
@@ -19,21 +19,15 @@ package org.apache.camel.component.platform.http.vertx;
import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.model.rest.RestBindingMode;
-import org.apache.camel.test.AvailablePortFinder;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.RegisterExtension;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
public class VertxInvalidJSonClientResponseValidationTest {
-
- @RegisterExtension
- AvailablePortFinder.Port port = AvailablePortFinder.find();
-
@Test
public void testInvalidJSon() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
try {
context.addRoutes(new RouteBuilder() {
@@ -52,7 +46,7 @@ public class VertxInvalidJSonClientResponseValidationTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
given()
.when()
diff --git
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformEventNotifierTest.java
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformEventNotifierTest.java
index 551a9737f7b4..7eb326ca8f9f 100644
---
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformEventNotifierTest.java
+++
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformEventNotifierTest.java
@@ -24,24 +24,18 @@ import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.spi.CamelEvent;
import org.apache.camel.support.EventNotifierSupport;
-import org.apache.camel.test.AvailablePortFinder;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.RegisterExtension;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.is;
public class VertxPlatformEventNotifierTest {
-
- @RegisterExtension
- AvailablePortFinder.Port port = AvailablePortFinder.find();
-
private final List<String> events = new ArrayList<>();
@Test
void testEventNotifierOk() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
context.getManagementStrategy().addEventNotifier(new
MyEventListener());
events.clear();
@@ -54,7 +48,7 @@ public class VertxPlatformEventNotifierTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
given()
.body("Hello World")
@@ -73,7 +67,7 @@ public class VertxPlatformEventNotifierTest {
@Test
void testEventNotifierError() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
context.getManagementStrategy().addEventNotifier(new
MyEventListener());
events.clear();
@@ -86,7 +80,7 @@ public class VertxPlatformEventNotifierTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
given()
.body("Hello World")
diff --git
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpBasicTest.java
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpBasicTest.java
index 89cbf7ce0062..5f67658dbd9e 100644
---
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpBasicTest.java
+++
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpBasicTest.java
@@ -18,21 +18,16 @@ package org.apache.camel.component.platform.http.vertx;
import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.AvailablePortFinder;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.RegisterExtension;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.is;
public class VertxPlatformHttpBasicTest {
- @RegisterExtension
- AvailablePortFinder.Port port = AvailablePortFinder.find();
-
@Test
void testBasicOk() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
try {
context.addRoutes(new RouteBuilder() {
@@ -46,7 +41,7 @@ public class VertxPlatformHttpBasicTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
given()
.body("Hello World")
@@ -61,7 +56,7 @@ public class VertxPlatformHttpBasicTest {
@Test
void testBasicError() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
try {
context.addRoutes(new RouteBuilder() {
@@ -72,7 +67,7 @@ public class VertxPlatformHttpBasicTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
given()
.body("Hello World")
diff --git
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpEngineTest.java
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpEngineTest.java
index c5c307b8a044..d8f89c92f2f9 100644
---
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpEngineTest.java
+++
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpEngineTest.java
@@ -1352,6 +1352,10 @@ public class VertxPlatformHttpEngineTest {
return createCamelContext(port.getPort(), customizer);
}
+ static CamelContext createCamelContext() throws Exception {
+ return createCamelContext(0, null);
+ }
+
static CamelContext createCamelContext(int port) throws Exception {
return createCamelContext(port, null);
}
@@ -1360,7 +1364,9 @@ public class VertxPlatformHttpEngineTest {
VertxPlatformHttpServerConfiguration conf = new
VertxPlatformHttpServerConfiguration();
conf.setBindPort(port);
- RestAssured.port = port;
+ if (port != 0) {
+ RestAssured.port = port;
+ }
if (customizer != null) {
customizer.customize(conf);
@@ -1371,6 +1377,14 @@ public class VertxPlatformHttpEngineTest {
return context;
}
+ static void startCamelContext(CamelContext context) throws Exception {
+ context.start();
+ VertxPlatformHttpServer server =
context.hasService(VertxPlatformHttpServer.class);
+ if (server != null) {
+ RestAssured.port = server.getPort();
+ }
+ }
+
interface ServerConfigurationCustomizer {
void customize(VertxPlatformHttpServerConfiguration configuration);
}
diff --git
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpEngineWithTypeConverterTest.java
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpEngineWithTypeConverterTest.java
index 9376f4f95e1f..bb88384b1464 100644
---
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpEngineWithTypeConverterTest.java
+++
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpEngineWithTypeConverterTest.java
@@ -28,21 +28,15 @@ import org.apache.camel.Exchange;
import org.apache.camel.TypeConversionException;
import org.apache.camel.TypeConverter;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.AvailablePortFinder;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.RegisterExtension;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
public class VertxPlatformHttpEngineWithTypeConverterTest {
-
- @RegisterExtension
- AvailablePortFinder.Port port = AvailablePortFinder.find();
-
@Test
public void testByteBufferConversion() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
TypeConverter tc = mockByteBufferTypeConverter();
context.getTypeConverterRegistry().addTypeConverter(ByteBuffer.class,
Map.class, tc);
@@ -57,7 +51,7 @@ public class VertxPlatformHttpEngineWithTypeConverterTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
given()
.when()
@@ -72,7 +66,7 @@ public class VertxPlatformHttpEngineWithTypeConverterTest {
@Test
public void testInputStreamConversion() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
TypeConverter tc = mockInputStreamTypeConverter();
context.getTypeConverterRegistry().addTypeConverter(InputStream.class,
Map.class, tc);
@@ -87,7 +81,7 @@ public class VertxPlatformHttpEngineWithTypeConverterTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
given()
.when()
diff --git
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpFileResponseTest.java
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpFileResponseTest.java
index f085f2a1c77c..d2fea726eae3 100644
---
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpFileResponseTest.java
+++
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpFileResponseTest.java
@@ -20,21 +20,15 @@ import java.io.File;
import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.AvailablePortFinder;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.RegisterExtension;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.is;
public class VertxPlatformHttpFileResponseTest {
-
- @RegisterExtension
- AvailablePortFinder.Port port = AvailablePortFinder.find();
-
@Test
void testFileResponse() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
final File file = new File("src/test/resources/dummy.txt");
try {
@@ -46,7 +40,7 @@ public class VertxPlatformHttpFileResponseTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
String requestBody = "Give me a file";
given()
@@ -62,7 +56,7 @@ public class VertxPlatformHttpFileResponseTest {
@Test
void testFileEndpointResponse() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
try {
context.addRoutes(new RouteBuilder() {
@@ -73,7 +67,7 @@ public class VertxPlatformHttpFileResponseTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
String requestBody = "Give me a file";
given()
diff --git
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpJacksonTest.java
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpJacksonTest.java
index 65e0cab9daf2..e3bd6c8e9e87 100644
---
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpJacksonTest.java
+++
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpJacksonTest.java
@@ -19,21 +19,15 @@ package org.apache.camel.component.platform.http.vertx;
import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.jackson.JacksonConstants;
-import org.apache.camel.test.AvailablePortFinder;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.RegisterExtension;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
public class VertxPlatformHttpJacksonTest {
-
- @RegisterExtension
- AvailablePortFinder.Port port = AvailablePortFinder.find();
-
@Test
public void testJackson() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
try {
// turn on jackson type converter
@@ -48,7 +42,7 @@ public class VertxPlatformHttpJacksonTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
given()
.when()
diff --git
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpLargeMessageStreamingTest.java
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpLargeMessageStreamingTest.java
index 11f2883812fd..fe212200e66d 100644
---
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpLargeMessageStreamingTest.java
+++
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpLargeMessageStreamingTest.java
@@ -26,24 +26,18 @@ import java.util.Random;
import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.AvailablePortFinder;
import org.apache.camel.util.IOHelper;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
-import org.junit.jupiter.api.extension.RegisterExtension;
import static io.restassured.RestAssured.given;
import static org.junit.jupiter.api.Assertions.assertEquals;
@EnabledIfSystemProperty(named = "performance-tests", matches = ".*")
public class VertxPlatformHttpLargeMessageStreamingTest {
-
- @RegisterExtension
- AvailablePortFinder.Port port = AvailablePortFinder.find();
-
@Test
void testStreamingWithLargeRequestAndResponseBody() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
context.getStreamCachingStrategy().setSpoolEnabled(true);
Path input = createLargeFile();
@@ -58,7 +52,7 @@ public class VertxPlatformHttpLargeMessageStreamingTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
InputStream response = given()
.body(new FileInputStream(input.toFile()))
diff --git
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpStreamingTest.java
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpStreamingTest.java
index 299980d0ea01..1b64f94c5ae9 100644
---
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpStreamingTest.java
+++
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpStreamingTest.java
@@ -28,10 +28,8 @@ import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.AvailablePortFinder;
import org.apache.camel.util.IOHelper;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.RegisterExtension;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.emptyOrNullString;
@@ -39,13 +37,9 @@ import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class VertxPlatformHttpStreamingTest {
-
- @RegisterExtension
- AvailablePortFinder.Port port = AvailablePortFinder.find();
-
@Test
void testStreamingWithStringRequestAndResponseBody() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
try {
context.addRoutes(new RouteBuilder() {
@@ -56,7 +50,7 @@ public class VertxPlatformHttpStreamingTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
String requestBody = "Vert.x Platform HTTP";
given()
@@ -72,7 +66,7 @@ public class VertxPlatformHttpStreamingTest {
@Test
void testStreamingWithFileRequestAndResponseBody() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
String content = "Hello World";
Path testFile = Files.createTempFile("platform-http-testing", "txt");
Files.writeString(testFile, content);
@@ -86,7 +80,7 @@ public class VertxPlatformHttpStreamingTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
given()
.body(testFile.toFile())
@@ -102,7 +96,7 @@ public class VertxPlatformHttpStreamingTest {
@Test
void testPopulateOnlyHeadersWithFormUrlEncodedBody() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
try {
context.addRoutes(new RouteBuilder() {
@Override
@@ -112,7 +106,7 @@ public class VertxPlatformHttpStreamingTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
given()
.contentType(ContentType.URLENC)
@@ -129,7 +123,7 @@ public class VertxPlatformHttpStreamingTest {
@Test
void testStreamingWithFormUrlEncodedBody() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
try {
context.addRoutes(new RouteBuilder() {
@Override
@@ -139,7 +133,7 @@ public class VertxPlatformHttpStreamingTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
given()
.contentType(ContentType.URLENC)
@@ -159,7 +153,7 @@ public class VertxPlatformHttpStreamingTest {
Path testFile = Files.createTempFile("platform-http-testing", "txt");
Files.writeString(testFile, content);
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort(), configuration ->
{
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(0, configuration -> {
VertxPlatformHttpServerConfiguration.BodyHandler bodyHandler
= new VertxPlatformHttpServerConfiguration.BodyHandler();
// turn on file uploads
@@ -177,7 +171,7 @@ public class VertxPlatformHttpStreamingTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
given()
.multiPart(testFile.toFile())
@@ -192,7 +186,7 @@ public class VertxPlatformHttpStreamingTest {
@Test
void testStreamingWithSpecificEncoding() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
Path input = Files.createTempFile("platform-http-input", "dat");
Path output = Files.createTempFile("platform-http-output", "dat");
@@ -208,7 +202,7 @@ public class VertxPlatformHttpStreamingTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
InputStream response = given()
.body(new FileInputStream(input.toFile()))
@@ -231,7 +225,7 @@ public class VertxPlatformHttpStreamingTest {
@Test
void testStreamingWithClosedInputStreamResponse() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
try {
context.addRoutes(new RouteBuilder() {
@Override
@@ -252,7 +246,7 @@ public class VertxPlatformHttpStreamingTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
given()
.get("/streaming")
@@ -265,7 +259,7 @@ public class VertxPlatformHttpStreamingTest {
@Test
void testStreamingWithUnconvertableResponseType() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
try {
context.addRoutes(new RouteBuilder() {
@Override
@@ -281,7 +275,7 @@ public class VertxPlatformHttpStreamingTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
given()
.get("/streaming")
diff --git
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformServerRequestValidationTest.java
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformServerRequestValidationTest.java
index 8d1bc9784e0a..5c5d41d96edd 100644
---
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformServerRequestValidationTest.java
+++
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformServerRequestValidationTest.java
@@ -19,21 +19,15 @@ package org.apache.camel.component.platform.http.vertx;
import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.platform.http.PlatformHttpComponent;
-import org.apache.camel.test.AvailablePortFinder;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.RegisterExtension;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.is;
public class VertxPlatformServerRequestValidationTest {
-
- @RegisterExtension
- AvailablePortFinder.Port port = AvailablePortFinder.find();
-
@Test
void testServerRequestFalse() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
try {
context.addRoutes(new RouteBuilder() {
@@ -55,7 +49,7 @@ public class VertxPlatformServerRequestValidationTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
given()
.body("<hello>World</hello>")
@@ -80,7 +74,7 @@ public class VertxPlatformServerRequestValidationTest {
@Test
void testServerRequestTrue() throws Exception {
- final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext(port.getPort());
+ final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
try {
context.addRoutes(new RouteBuilder() {
@@ -102,7 +96,7 @@ public class VertxPlatformServerRequestValidationTest {
}
});
- context.start();
+ VertxPlatformHttpEngineTest.startCamelContext(context);
given()
.body("<hello>World</hello>")