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 e8928b0 Fix camel-rest-openapi not creating producer correctly. e8928b0 is described below commit e8928b040c9a2868759824f7b91f65e4aade8860 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Tue Feb 22 19:36:08 2022 +0100 Fix camel-rest-openapi not creating producer correctly. --- components/camel-rest-openapi/pom.xml | 6 ++ .../rest/openapi/RestOpenApiEndpoint.java | 2 +- .../rest/openapi/RestOpenApiProducer.java | 5 +- .../camel/component/rest/openapi/HttpsTest.java | 3 +- .../camel/component/rest/openapi/HttpsV3Test.java | 1 + components/camel-vertx/camel-vertx-http/pom.xml | 10 --- .../vertx/http/VertxHttpRestProducerTest.java | 78 ---------------------- components/pom.xml | 3 +- 8 files changed, 14 insertions(+), 94 deletions(-) diff --git a/components/camel-rest-openapi/pom.xml b/components/camel-rest-openapi/pom.xml index 9da7c1c..7eed843 100644 --- a/components/camel-rest-openapi/pom.xml +++ b/components/camel-rest-openapi/pom.xml @@ -143,6 +143,12 @@ </dependency> <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-vertx-http</artifactId> + <scope>test</scope> + </dependency> + + <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-slf4j-impl</artifactId> <scope>test</scope> diff --git a/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiEndpoint.java b/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiEndpoint.java index 6836bde..96dd026 100644 --- a/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiEndpoint.java +++ b/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiEndpoint.java @@ -358,7 +358,7 @@ public final class RestOpenApiEndpoint extends DefaultEndpoint { // if there is a host then we should use this hardcoded host instead of any Header that may have an existing // Host header from some other HTTP input, and if so then lets remove it - return new RestOpenApiProducer(endpoint.createAsyncProducer(), hasHost); + return new RestOpenApiProducer(endpoint.createProducer(), hasHost); } String determineBasePath(final Document openapi) { diff --git a/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiProducer.java b/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiProducer.java index 25dcf07..4cac066 100644 --- a/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiProducer.java +++ b/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiProducer.java @@ -22,14 +22,15 @@ import org.apache.camel.AsyncCallback; import org.apache.camel.AsyncProducer; import org.apache.camel.Endpoint; import org.apache.camel.Exchange; +import org.apache.camel.Producer; import org.apache.camel.support.processor.DelegateAsyncProcessor; public class RestOpenApiProducer extends DelegateAsyncProcessor implements AsyncProducer { - private final AsyncProducer delegate; + private final Producer delegate; private final boolean removeHostHeader; - public RestOpenApiProducer(AsyncProducer delegate, boolean removeHostHeader) { + public RestOpenApiProducer(Producer delegate, boolean removeHostHeader) { super(delegate); this.delegate = delegate; this.removeHostHeader = removeHostHeader; diff --git a/components/camel-rest-openapi/src/test/java/org/apache/camel/component/rest/openapi/HttpsTest.java b/components/camel-rest-openapi/src/test/java/org/apache/camel/component/rest/openapi/HttpsTest.java index c97be88..a82242d 100644 --- a/components/camel-rest-openapi/src/test/java/org/apache/camel/component/rest/openapi/HttpsTest.java +++ b/components/camel-rest-openapi/src/test/java/org/apache/camel/component/rest/openapi/HttpsTest.java @@ -143,10 +143,9 @@ public abstract class HttpsTest extends CamelTestSupport { public static Iterable<String> knownProducers() { final List<String> producers = new ArrayList<>(Arrays.asList(RestEndpoint.DEFAULT_REST_PRODUCER_COMPONENTS)); - // skip http due security certificate testing problems + producers.remove("vertx-http"); producers.remove("http"); - return producers; } diff --git a/components/camel-rest-openapi/src/test/java/org/apache/camel/component/rest/openapi/HttpsV3Test.java b/components/camel-rest-openapi/src/test/java/org/apache/camel/component/rest/openapi/HttpsV3Test.java index 1b37fa4..9170e6d 100644 --- a/components/camel-rest-openapi/src/test/java/org/apache/camel/component/rest/openapi/HttpsV3Test.java +++ b/components/camel-rest-openapi/src/test/java/org/apache/camel/component/rest/openapi/HttpsV3Test.java @@ -144,6 +144,7 @@ public abstract class HttpsV3Test extends CamelTestSupport { public static Iterable<String> knownProducers() { final List<String> producers = new ArrayList<>(Arrays.asList(RestEndpoint.DEFAULT_REST_PRODUCER_COMPONENTS)); // skip http due security certificate testing problems + producers.remove("vertx-http"); producers.remove("http"); return producers; } diff --git a/components/camel-vertx/camel-vertx-http/pom.xml b/components/camel-vertx/camel-vertx-http/pom.xml index 89f7563..2ba7a42 100644 --- a/components/camel-vertx/camel-vertx-http/pom.xml +++ b/components/camel-vertx/camel-vertx-http/pom.xml @@ -70,15 +70,5 @@ <artifactId>camel-undertow</artifactId> <scope>test</scope> </dependency> - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-rest-openapi</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-openapi-java</artifactId> - <scope>test</scope> - </dependency> </dependencies> </project> diff --git a/components/camel-vertx/camel-vertx-http/src/test/java/org/apache/camel/component/vertx/http/VertxHttpRestProducerTest.java b/components/camel-vertx/camel-vertx-http/src/test/java/org/apache/camel/component/vertx/http/VertxHttpRestProducerTest.java deleted file mode 100644 index 630ef8d..0000000 --- a/components/camel-vertx/camel-vertx-http/src/test/java/org/apache/camel/component/vertx/http/VertxHttpRestProducerTest.java +++ /dev/null @@ -1,78 +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.component.vertx.http; - -import java.io.InputStream; -import java.net.URI; - -import org.apache.camel.CamelContext; -import org.apache.camel.Exchange; -import org.apache.camel.Processor; -import org.apache.camel.RoutesBuilder; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.rest.openapi.RestOpenApiComponent; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class VertxHttpRestProducerTest extends VertxHttpTestSupport { - - @Test - public void testVertxHttpRestProducer() throws InterruptedException { - String response = template.requestBodyAndHeader("petstore:getPetById", null, "petId", 1, String.class); - assertNotNull(response); - assertTrue(response.contains("\"name\": \"Cat 1\"")); - } - - @Override - protected CamelContext createCamelContext() throws Exception { - CamelContext camelContext = super.createCamelContext(); - RestOpenApiComponent petstore = new RestOpenApiComponent(camelContext); - petstore.setHost(getTestServerUrl()); - petstore.setSpecificationUri(new URI(getTestServerUrl() + "/api/v3/petstore.json")); - petstore.setComponentName("vertx-http"); - camelContext.addComponent("petstore", petstore); - return camelContext; - } - - @Override - protected RoutesBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - from(getTestServerUri() + "/api/v3/petstore.json").process(new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - InputStream stream = VertxHttpRestProducerTest.class.getResourceAsStream("/openapi/petstore.json"); - String json = exchange.getContext().getTypeConverter().convertTo(String.class, stream); - exchange.getMessage().setBody(json); - } - }); - - from(getTestServerUri() + "/api/v3/pet/?matchOnUriPrefix=true").process(new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - InputStream stream = VertxHttpRestProducerTest.class.getResourceAsStream("/openapi/pet.json"); - String json = exchange.getContext().getTypeConverter().convertTo(String.class, stream); - exchange.getMessage().setBody(json); - } - }); - } - }; - } -} diff --git a/components/pom.xml b/components/pom.xml index 1b6c661..eb33a2d 100644 --- a/components/pom.xml +++ b/components/pom.xml @@ -279,7 +279,6 @@ <module>camel-resourceresolver-github</module> <module>camel-resteasy</module> <module>camel-rest-swagger</module> - <module>camel-rest-openapi</module> <module>camel-robotframework</module> <module>camel-rss</module> <module>camel-rxjava</module> @@ -356,6 +355,8 @@ <module>camel-zipkin</module> <module>camel-zookeeper-master</module> <module>camel-zookeeper</module> + <!-- build rest-openapi at end as it uses all the http based components --> + <module>camel-rest-openapi</module> <!-- build jooq last as it cause component builds to be slower afterwards --> <module>camel-jooq</module> </modules>