This is an automated email from the ASF dual-hosted git repository. cdeppisch pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git
commit fa70664e2688ffdfd5b1d586b653ac76db67f382 Author: Christoph Deppisch <cdeppi...@redhat.com> AuthorDate: Thu May 8 12:55:41 2025 +0200 chore: Fix tests with Citrus 4.6.0 --- pom.xml | 13 ++- tests/camel-kamelets-itest/README.md | 4 +- tests/camel-kamelets-itest/pom.xml | 2 +- .../camel-kamelets-itest/src/test/java/AvroIT.java | 48 +++++++++ .../camel-kamelets-itest/src/test/java/AwsIT.java | 67 ++++++++++++ .../test/java/{KameletsIT.java => CommonIT.java} | 67 ++++++------ .../src/test/java/EndpointAutoConfiguration.java | 117 --------------------- .../camel-kamelets-itest/src/test/java/JiraIT.java | 67 ++++++++++++ .../src/test/java/KafkaIT.java | 69 ++++++++++++ .../camel-kamelets-itest/src/test/java/MailIT.java | 33 ++++++ .../src/test/java/OpenApiIT.java | 68 ++++++++++++ .../src/test/java/ProtobufIT.java | 47 +++++++++ .../src/test/java/SlackIT.java | 66 ++++++++++++ .../resources/avro/avro-binary-source-pipe.yaml | 2 +- .../src/test/resources/avro/avro-data-type.it.yaml | 5 + .../test/resources/avro/avro-serdes-action.it.yaml | 5 + .../test/resources/avro/avro-serialize-pipe.yaml | 2 +- .../test/resources/aws/s3/aws-s3-to-http.it.yaml | 4 +- .../test/resources/citrus-application.properties | 29 +++-- .../src/test/resources/junit-platform.properties | 19 ++++ .../test/resources/kafka/kafka-router-pipe.it.yaml | 7 +- .../test/resources/kafka/kafka-source-pipe.it.yaml | 4 +- .../protobuf/protobuf-binary-source-pipe.yaml | 2 +- .../resources/protobuf/protobuf-data-type.it.yaml | 5 + .../protobuf/protobuf-serdes-action.it.yaml | 5 + .../protobuf/protobuf-serialize-pipe.yaml | 2 +- 26 files changed, 576 insertions(+), 183 deletions(-) diff --git a/pom.xml b/pom.xml index 46f09143c..9fa3013cb 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ <parent> <groupId>org.apache.camel</groupId> <artifactId>camel-dependencies</artifactId> - <version>4.11.0</version> + <version>4.11.0</version> </parent> <groupId>org.apache.camel.kamelets</groupId> @@ -65,7 +65,6 @@ <camel.version>4.11.0</camel.version> <citrus.version>4.6.0</citrus.version> - <cucumber.version>7.20.1</cucumber.version> <!-- Versions used inside Kamelets (add them also to the dependencyManagement section and the groovy script below) --> <!-- These properties must keep this same format "version.<groupId>.<artifactId>" --> @@ -73,11 +72,11 @@ <version.com.amazon.redshift.redshift-jdbc42>2.1.0.32</version.com.amazon.redshift.redshift-jdbc42> <version.org.apache.activemq.artemis-jakarta-client-all>2.41.0</version.org.apache.activemq.artemis-jakarta-client-all> <version.org.messaginghub.pooled-jms>3.1.7</version.org.messaginghub.pooled-jms> - <version.org.postgresql.postgresql>42.7.5</version.org.postgresql.postgresql> - <version.net.snowflake.snowflake-jdbc>3.22.0</version.net.snowflake.snowflake-jdbc> - <version.io.quarkus.quarkus-apicurio-registry-avro>3.18.1</version.io.quarkus.quarkus-apicurio-registry-avro> - <!-- These versions should be taken from Azure SDK BOM used in the Camel version declared --> - <version.com.azure.azure-identity>1.15.0</version.com.azure.azure-identity> + <version.org.postgresql.postgresql>42.7.5</version.org.postgresql.postgresql> + <version.net.snowflake.snowflake-jdbc>3.22.0</version.net.snowflake.snowflake-jdbc> + <version.io.quarkus.quarkus-apicurio-registry-avro>3.18.1</version.io.quarkus.quarkus-apicurio-registry-avro> + <!-- These versions should be taken from Azure SDK BOM used in the Camel version declared --> + <version.com.azure.azure-identity>1.15.0</version.com.azure.azure-identity> <version.com.azure.azure-data-schemaregistry-apacheavro>1.1.23</version.com.azure.azure-data-schemaregistry-apacheavro> <version.com.microsoft.azure.azure-schemaregistry-kafka-avro>1.1.1</version.com.microsoft.azure.azure-schemaregistry-kafka-avro> </properties> diff --git a/tests/camel-kamelets-itest/README.md b/tests/camel-kamelets-itest/README.md index 104102479..b246c2378 100644 --- a/tests/camel-kamelets-itest/README.md +++ b/tests/camel-kamelets-itest/README.md @@ -16,10 +16,10 @@ Once everything is set you just need to run This runs all available Citrus tests. -You can run individual tests when specifying its folder name on the class `KameletsIT` (e.g. `aws`). +You can run individual tests when specifying its folder name on the class `CommonIT` (e.g. `timer`). ```console - mvn verify -Dtest=KameletsIT#aws + mvn verify -Dtest=CommonIT#timer ``` You can run the tests also from your favorite Java IDE. diff --git a/tests/camel-kamelets-itest/pom.xml b/tests/camel-kamelets-itest/pom.xml index 45898b602..41ce5791b 100644 --- a/tests/camel-kamelets-itest/pom.xml +++ b/tests/camel-kamelets-itest/pom.xml @@ -34,7 +34,7 @@ <description>Camel Kamelets Integration Tests</description> <properties> - <enable.integration.tests>*KameletsIT</enable.integration.tests> + <enable.integration.tests>*IT</enable.integration.tests> </properties> <dependencyManagement> diff --git a/tests/camel-kamelets-itest/src/test/java/AvroIT.java b/tests/camel-kamelets-itest/src/test/java/AvroIT.java new file mode 100644 index 000000000..41e7be04b --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/java/AvroIT.java @@ -0,0 +1,48 @@ +/* + * 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. + */ + +import java.util.stream.Stream; + +import org.citrusframework.common.TestLoader; +import org.citrusframework.container.SequenceBeforeTest; +import org.citrusframework.junit.jupiter.CitrusSupport; +import org.citrusframework.junit.jupiter.CitrusTestFactory; +import org.citrusframework.junit.jupiter.CitrusTestFactorySupport; +import org.citrusframework.spi.BindToRegistry; +import org.citrusframework.util.SocketUtils; +import org.junit.jupiter.api.DynamicTest; + +import static org.citrusframework.actions.CreateVariablesAction.Builder.createVariables; + +@CitrusSupport +public class AvroIT { + + private final int avroWebhookPort = SocketUtils.findAvailableTcpPort(); + + @BindToRegistry + public SequenceBeforeTest beforeAvro() { + return new SequenceBeforeTest.Builder().onTests("avro-*").actions( + createVariables().variable("avro.webhook.server.port", String.valueOf(avroWebhookPort)) + ).build(); + } + + @CitrusTestFactory + public Stream<DynamicTest> avro() { + return CitrusTestFactorySupport.factory(TestLoader.YAML).packageScan("avro"); + } + +} diff --git a/tests/camel-kamelets-itest/src/test/java/AwsIT.java b/tests/camel-kamelets-itest/src/test/java/AwsIT.java new file mode 100644 index 000000000..5490ca0dd --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/java/AwsIT.java @@ -0,0 +1,67 @@ +/* + * 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. + */ + +import java.util.stream.Stream; + +import org.citrusframework.common.TestLoader; +import org.citrusframework.container.SequenceAfterTest; +import org.citrusframework.container.SequenceBeforeTest; +import org.citrusframework.http.server.HttpServer; +import org.citrusframework.junit.jupiter.CitrusSupport; +import org.citrusframework.junit.jupiter.CitrusTestFactory; +import org.citrusframework.junit.jupiter.CitrusTestFactorySupport; +import org.citrusframework.spi.BindToRegistry; +import org.citrusframework.util.SocketUtils; +import org.junit.jupiter.api.DynamicTest; + +import static org.citrusframework.actions.CreateVariablesAction.Builder.createVariables; +import static org.citrusframework.actions.PurgeEndpointAction.Builder.purgeEndpoints; +import static org.citrusframework.http.endpoint.builder.HttpEndpoints.http; + +@CitrusSupport +public class AwsIT { + + private final int awsSinkServerPort = SocketUtils.findAvailableTcpPort(); + + @BindToRegistry + HttpServer awsSinkServer = http() + .server() + .port(awsSinkServerPort) + .timeout(10000L) + .autoStart(true) + .build(); + + @BindToRegistry + public SequenceBeforeTest beforeAws() { + return new SequenceBeforeTest.Builder().onTests("aws-*").actions( + createVariables().variable("aws.sink.server.port", String.valueOf(awsSinkServerPort)) + ).build(); + } + + @BindToRegistry + public SequenceAfterTest afterAws() { + return new SequenceAfterTest.Builder().onTests("aws-*").actions( + purgeEndpoints().endpoint(awsSinkServer) + ).build(); + } + + @CitrusTestFactory + public Stream<DynamicTest> aws() { + return CitrusTestFactorySupport.factory(TestLoader.YAML).packageScan("aws"); + } + +} diff --git a/tests/camel-kamelets-itest/src/test/java/KameletsIT.java b/tests/camel-kamelets-itest/src/test/java/CommonIT.java similarity index 56% rename from tests/camel-kamelets-itest/src/test/java/KameletsIT.java rename to tests/camel-kamelets-itest/src/test/java/CommonIT.java index 071c5f7fc..1e6425b1f 100644 --- a/tests/camel-kamelets-itest/src/test/java/KameletsIT.java +++ b/tests/camel-kamelets-itest/src/test/java/CommonIT.java @@ -18,57 +18,50 @@ import java.util.stream.Stream; import org.citrusframework.common.TestLoader; +import org.citrusframework.container.SequenceAfterTest; +import org.citrusframework.container.SequenceBeforeTest; +import org.citrusframework.http.server.HttpServer; import org.citrusframework.junit.jupiter.CitrusSupport; import org.citrusframework.junit.jupiter.CitrusTestFactory; import org.citrusframework.junit.jupiter.CitrusTestFactorySupport; +import org.citrusframework.spi.BindToRegistry; +import org.citrusframework.util.SocketUtils; import org.junit.jupiter.api.DynamicTest; -@CitrusSupport -public class KameletsIT { - - @CitrusTestFactory - public Stream<DynamicTest> avro() { - return CitrusTestFactorySupport.factory(TestLoader.YAML).packageScan("avro"); - } - - @CitrusTestFactory - public Stream<DynamicTest> aws() { - return CitrusTestFactorySupport.factory(TestLoader.YAML).packageScan("aws"); - } - - @CitrusTestFactory - public Stream<DynamicTest> earthquake() { - return CitrusTestFactorySupport.factory(TestLoader.YAML).packageScan("earthquake"); - } +import static org.citrusframework.actions.CreateVariablesAction.Builder.createVariables; +import static org.citrusframework.actions.PurgeEndpointAction.Builder.purgeEndpoints; +import static org.citrusframework.http.endpoint.builder.HttpEndpoints.http; - @CitrusTestFactory - public Stream<DynamicTest> jira() { - return CitrusTestFactorySupport.factory(TestLoader.YAML).packageScan("jira"); - } +@CitrusSupport +public class CommonIT { - @CitrusTestFactory - public Stream<DynamicTest> kafka() { - return CitrusTestFactorySupport.factory(TestLoader.YAML).packageScan("kafka"); - } + private final int httpServerPort = SocketUtils.findAvailableTcpPort(); - @CitrusTestFactory - public Stream<DynamicTest> mail() { - return CitrusTestFactorySupport.factory(TestLoader.YAML).packageScan("mail"); - } + @BindToRegistry + HttpServer httpServer = http() + .server() + .port(httpServerPort) + .timeout(60000L) + .autoStart(true) + .build(); - @CitrusTestFactory - public Stream<DynamicTest> openapi() { - return CitrusTestFactorySupport.factory(TestLoader.YAML).packageScan("openapi"); + @BindToRegistry + public SequenceBeforeTest beforeCommon() { + return new SequenceBeforeTest.Builder().actions( + createVariables().variable("http.server.port", String.valueOf(httpServerPort)) + ).build(); } - @CitrusTestFactory - public Stream<DynamicTest> protobuf() { - return CitrusTestFactorySupport.factory(TestLoader.YAML).packageScan("protobuf"); + @BindToRegistry + public SequenceAfterTest afterCommon() { + return new SequenceAfterTest.Builder().actions( + purgeEndpoints().endpoint(httpServer) + ).build(); } @CitrusTestFactory - public Stream<DynamicTest> slack() { - return CitrusTestFactorySupport.factory(TestLoader.YAML).packageScan("slack"); + public Stream<DynamicTest> earthquake() { + return CitrusTestFactorySupport.factory(TestLoader.YAML).packageScan("earthquake"); } @CitrusTestFactory diff --git a/tests/camel-kamelets-itest/src/test/java/EndpointAutoConfiguration.java b/tests/camel-kamelets-itest/src/test/java/EndpointAutoConfiguration.java deleted file mode 100644 index 87c933057..000000000 --- a/tests/camel-kamelets-itest/src/test/java/EndpointAutoConfiguration.java +++ /dev/null @@ -1,117 +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. - */ - -import org.citrusframework.annotations.CitrusConfiguration; -import org.citrusframework.container.SequenceAfterTest; -import org.citrusframework.container.SequenceBeforeTest; -import org.citrusframework.http.server.HttpServer; -import org.citrusframework.spi.BindToRegistry; -import org.citrusframework.util.SocketUtils; -import org.springframework.http.HttpStatus; - -import static org.citrusframework.actions.CreateVariablesAction.Builder.createVariables; -import static org.citrusframework.actions.PurgeEndpointAction.Builder.purgeEndpoints; -import static org.citrusframework.http.endpoint.builder.HttpEndpoints.http; - -@CitrusConfiguration -public class EndpointAutoConfiguration { - - private static final long SERVER_TIMEOUT = 60000L; - - private static final int HTTP_SERVER_PORT = SocketUtils.findAvailableTcpPort(8801); - private static final int SLACK_SERVER_PORT = SocketUtils.findAvailableTcpPort(8802); - private static final int PETSTORE_SERVER_PORT = SocketUtils.findAvailableTcpPort(8803); - private static final int JIRA_SERVER_PORT = SocketUtils.findAvailableTcpPort(8804); - - private final HttpServer httpServer = http() - .server() - .port(HTTP_SERVER_PORT) - .timeout(SERVER_TIMEOUT) - .autoStart(true) - .build(); - - private final HttpServer slackServer = http() - .server() - .port(SLACK_SERVER_PORT) - .timeout(SERVER_TIMEOUT) - .autoStart(true) - .build(); - - private final HttpServer petstoreServer = http() - .server() - .port(PETSTORE_SERVER_PORT) - .timeout(SERVER_TIMEOUT) - .defaultStatus(HttpStatus.CREATED) - .autoStart(true) - .build(); - - private final HttpServer jiraServer = http() - .server() - .port(JIRA_SERVER_PORT) - .timeout(SERVER_TIMEOUT) - .autoStart(true) - .build(); - - @BindToRegistry - public HttpServer httpServer() { - return httpServer; - } - - @BindToRegistry - public HttpServer slackServer() { - return slackServer; - } - - @BindToRegistry - public HttpServer petstoreServer() { - return petstoreServer; - } - - @BindToRegistry - public HttpServer jiraServer() { - return jiraServer; - } - - @BindToRegistry - public SequenceBeforeTest beforeTest() { - return SequenceBeforeTest.Builder.beforeTest() - .actions( - // Set server ports as test variables - createVariables() - .variable("http.server.port", String.valueOf(HTTP_SERVER_PORT)) - .variable("slack.server.port", String.valueOf(SLACK_SERVER_PORT)) - .variable("petstore.server.port", String.valueOf(PETSTORE_SERVER_PORT)) - .variable("jira.server.port", String.valueOf(JIRA_SERVER_PORT)) - ) - .build(); - } - - @BindToRegistry - public SequenceAfterTest afterTest() { - return SequenceAfterTest.Builder.afterTest() - .actions( - // Auto purge Http server endpoint - purgeEndpoints() - .endpoint(httpServer) - .endpoint(slackServer) - .endpoint(petstoreServer) - .endpoint(jiraServer) - ) - .build(); - } - -} diff --git a/tests/camel-kamelets-itest/src/test/java/JiraIT.java b/tests/camel-kamelets-itest/src/test/java/JiraIT.java new file mode 100644 index 000000000..2af65e546 --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/java/JiraIT.java @@ -0,0 +1,67 @@ +/* + * 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. + */ + +import java.util.stream.Stream; + +import org.citrusframework.common.TestLoader; +import org.citrusframework.container.SequenceAfterTest; +import org.citrusframework.container.SequenceBeforeTest; +import org.citrusframework.http.server.HttpServer; +import org.citrusframework.junit.jupiter.CitrusSupport; +import org.citrusframework.junit.jupiter.CitrusTestFactory; +import org.citrusframework.junit.jupiter.CitrusTestFactorySupport; +import org.citrusframework.spi.BindToRegistry; +import org.citrusframework.util.SocketUtils; +import org.junit.jupiter.api.DynamicTest; + +import static org.citrusframework.actions.CreateVariablesAction.Builder.createVariables; +import static org.citrusframework.actions.PurgeEndpointAction.Builder.purgeEndpoints; +import static org.citrusframework.http.endpoint.builder.HttpEndpoints.http; + +@CitrusSupport +public class JiraIT { + + private final int jiraServerPort = SocketUtils.findAvailableTcpPort(); + + @BindToRegistry + HttpServer jiraServer = http() + .server() + .port(jiraServerPort) + .timeout(120000L) + .autoStart(true) + .build(); + + @BindToRegistry + public SequenceBeforeTest beforeJira() { + return new SequenceBeforeTest.Builder().onTests("jira-*").actions( + createVariables().variable("jira.server.port", String.valueOf(jiraServerPort)) + ).build(); + } + + @BindToRegistry + public SequenceAfterTest afterJira() { + return new SequenceAfterTest.Builder().onTests("jira-*").actions( + purgeEndpoints().endpoint(jiraServer) + ).build(); + } + + @CitrusTestFactory + public Stream<DynamicTest> jira() { + return CitrusTestFactorySupport.factory(TestLoader.YAML).packageScan("jira"); + } + +} diff --git a/tests/camel-kamelets-itest/src/test/java/KafkaIT.java b/tests/camel-kamelets-itest/src/test/java/KafkaIT.java new file mode 100644 index 000000000..cc62f86d2 --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/java/KafkaIT.java @@ -0,0 +1,69 @@ +/* + * 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. + */ + +import java.util.stream.Stream; + +import org.citrusframework.common.TestLoader; +import org.citrusframework.container.SequenceAfterTest; +import org.citrusframework.container.SequenceBeforeTest; +import org.citrusframework.http.server.HttpServer; +import org.citrusframework.junit.jupiter.CitrusSupport; +import org.citrusframework.junit.jupiter.CitrusTestFactory; +import org.citrusframework.junit.jupiter.CitrusTestFactorySupport; +import org.citrusframework.spi.BindToRegistry; +import org.citrusframework.util.SocketUtils; +import org.junit.jupiter.api.DynamicTest; + +import static org.citrusframework.actions.CreateVariablesAction.Builder.createVariables; +import static org.citrusframework.actions.PurgeEndpointAction.Builder.purgeEndpoints; +import static org.citrusframework.http.endpoint.builder.HttpEndpoints.http; + +@CitrusSupport +public class KafkaIT { + + private final int kafkaSinkServerPort = SocketUtils.findAvailableTcpPort(); + private final int kafkaWebhookPort = SocketUtils.findAvailableTcpPort(); + + @BindToRegistry + HttpServer kafkaSinkServer = http() + .server() + .port(kafkaSinkServerPort) + .timeout(10000L) + .autoStart(true) + .build(); + + @BindToRegistry + public SequenceBeforeTest beforeKafka() { + return new SequenceBeforeTest.Builder().onTests("kafka-*").actions( + createVariables() + .variable("kafka.sink.server.port", String.valueOf(kafkaSinkServerPort)) + .variable("kafka.webhook.server.port", String.valueOf(kafkaWebhookPort)) + ).build(); + } + + @BindToRegistry + public SequenceAfterTest afterKafka() { + return new SequenceAfterTest.Builder().onTests("kafka-*").actions( + purgeEndpoints().endpoint(kafkaSinkServer) + ).build(); + } + + @CitrusTestFactory + public Stream<DynamicTest> kafka() { + return CitrusTestFactorySupport.factory(TestLoader.YAML).packageScan("kafka"); + } +} diff --git a/tests/camel-kamelets-itest/src/test/java/MailIT.java b/tests/camel-kamelets-itest/src/test/java/MailIT.java new file mode 100644 index 000000000..e7eca53de --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/java/MailIT.java @@ -0,0 +1,33 @@ +/* + * 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. + */ + +import java.util.stream.Stream; + +import org.citrusframework.common.TestLoader; +import org.citrusframework.junit.jupiter.CitrusSupport; +import org.citrusframework.junit.jupiter.CitrusTestFactory; +import org.citrusframework.junit.jupiter.CitrusTestFactorySupport; +import org.junit.jupiter.api.DynamicTest; + +@CitrusSupport +public class MailIT { + + @CitrusTestFactory + public Stream<DynamicTest> mail() { + return CitrusTestFactorySupport.factory(TestLoader.YAML).packageScan("mail"); + } +} diff --git a/tests/camel-kamelets-itest/src/test/java/OpenApiIT.java b/tests/camel-kamelets-itest/src/test/java/OpenApiIT.java new file mode 100644 index 000000000..f35586b67 --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/java/OpenApiIT.java @@ -0,0 +1,68 @@ +/* + * 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. + */ + +import java.util.stream.Stream; + +import org.citrusframework.common.TestLoader; +import org.citrusframework.container.SequenceAfterTest; +import org.citrusframework.container.SequenceBeforeTest; +import org.citrusframework.http.server.HttpServer; +import org.citrusframework.junit.jupiter.CitrusSupport; +import org.citrusframework.junit.jupiter.CitrusTestFactory; +import org.citrusframework.junit.jupiter.CitrusTestFactorySupport; +import org.citrusframework.spi.BindToRegistry; +import org.citrusframework.util.SocketUtils; +import org.junit.jupiter.api.DynamicTest; +import org.springframework.http.HttpStatus; + +import static org.citrusframework.actions.CreateVariablesAction.Builder.createVariables; +import static org.citrusframework.actions.PurgeEndpointAction.Builder.purgeEndpoints; +import static org.citrusframework.http.endpoint.builder.HttpEndpoints.http; + +@CitrusSupport +public class OpenApiIT { + + private final int petstoreServerPort = SocketUtils.findAvailableTcpPort(); + + @BindToRegistry + HttpServer petstoreServer = http() + .server() + .port(petstoreServerPort) + .timeout(120000L) + .defaultStatus(HttpStatus.CREATED) + .autoStart(true) + .build(); + + @BindToRegistry + public SequenceBeforeTest beforeOpenApi() { + return new SequenceBeforeTest.Builder().onTests("rest-openapi-*").actions( + createVariables().variable("petstore.server.port", String.valueOf(petstoreServerPort)) + ).build(); + } + + @BindToRegistry + public SequenceAfterTest afterOpenApi() { + return new SequenceAfterTest.Builder().onTests("rest-openapi-*").actions( + purgeEndpoints().endpoint(petstoreServer) + ).build(); + } + + @CitrusTestFactory + public Stream<DynamicTest> openapi() { + return CitrusTestFactorySupport.factory(TestLoader.YAML).packageScan("openapi"); + } +} diff --git a/tests/camel-kamelets-itest/src/test/java/ProtobufIT.java b/tests/camel-kamelets-itest/src/test/java/ProtobufIT.java new file mode 100644 index 000000000..c75c1e186 --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/java/ProtobufIT.java @@ -0,0 +1,47 @@ +/* + * 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. + */ + +import java.util.stream.Stream; + +import org.citrusframework.common.TestLoader; +import org.citrusframework.container.SequenceBeforeTest; +import org.citrusframework.junit.jupiter.CitrusSupport; +import org.citrusframework.junit.jupiter.CitrusTestFactory; +import org.citrusframework.junit.jupiter.CitrusTestFactorySupport; +import org.citrusframework.spi.BindToRegistry; +import org.citrusframework.util.SocketUtils; +import org.junit.jupiter.api.DynamicTest; + +import static org.citrusframework.actions.CreateVariablesAction.Builder.createVariables; + +@CitrusSupport +public class ProtobufIT { + + private final int protobufWebhookPort = SocketUtils.findAvailableTcpPort(); + + @BindToRegistry + public SequenceBeforeTest beforeProtobuf() { + return new SequenceBeforeTest.Builder().onTests("protobuf-*").actions( + createVariables().variable("protobuf.webhook.server.port", String.valueOf(protobufWebhookPort)) + ).build(); + } + + @CitrusTestFactory + public Stream<DynamicTest> protobuf() { + return CitrusTestFactorySupport.factory(TestLoader.YAML).packageScan("protobuf"); + } +} diff --git a/tests/camel-kamelets-itest/src/test/java/SlackIT.java b/tests/camel-kamelets-itest/src/test/java/SlackIT.java new file mode 100644 index 000000000..9efc372e7 --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/java/SlackIT.java @@ -0,0 +1,66 @@ +/* + * 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. + */ + +import java.util.stream.Stream; + +import org.citrusframework.common.TestLoader; +import org.citrusframework.container.SequenceAfterTest; +import org.citrusframework.container.SequenceBeforeTest; +import org.citrusframework.http.server.HttpServer; +import org.citrusframework.junit.jupiter.CitrusSupport; +import org.citrusframework.junit.jupiter.CitrusTestFactory; +import org.citrusframework.junit.jupiter.CitrusTestFactorySupport; +import org.citrusframework.spi.BindToRegistry; +import org.citrusframework.util.SocketUtils; +import org.junit.jupiter.api.DynamicTest; + +import static org.citrusframework.actions.CreateVariablesAction.Builder.createVariables; +import static org.citrusframework.actions.PurgeEndpointAction.Builder.purgeEndpoints; +import static org.citrusframework.http.endpoint.builder.HttpEndpoints.http; + +@CitrusSupport +public class SlackIT { + + private final int slackServerPort = SocketUtils.findAvailableTcpPort(); + + @BindToRegistry + HttpServer slackServer = http() + .server() + .port(slackServerPort) + .timeout(120000L) + .autoStart(true) + .build(); + + @BindToRegistry + public SequenceBeforeTest beforeSlack() { + return new SequenceBeforeTest.Builder().onTests("slack-*").actions( + createVariables().variable("slack.server.port", String.valueOf(slackServerPort)) + ).build(); + } + + @BindToRegistry + public SequenceAfterTest afterSlack() { + return new SequenceAfterTest.Builder().onTests("slack-*").actions( + purgeEndpoints().endpoint(slackServer) + ).build(); + } + + @CitrusTestFactory + public Stream<DynamicTest> slack() { + return CitrusTestFactorySupport.factory(TestLoader.YAML).packageScan("slack"); + } +} diff --git a/tests/camel-kamelets-itest/src/test/resources/avro/avro-binary-source-pipe.yaml b/tests/camel-kamelets-itest/src/test/resources/avro/avro-binary-source-pipe.yaml index 703f2f4fa..989ed81a9 100644 --- a/tests/camel-kamelets-itest/src/test/resources/avro/avro-binary-source-pipe.yaml +++ b/tests/camel-kamelets-itest/src/test/resources/avro/avro-binary-source-pipe.yaml @@ -50,4 +50,4 @@ spec: properties: format: "avro-binary" sink: - uri: http://localhost:8080/user + uri: "{{http.sink.url}}" diff --git a/tests/camel-kamelets-itest/src/test/resources/avro/avro-data-type.it.yaml b/tests/camel-kamelets-itest/src/test/resources/avro/avro-data-type.it.yaml index 8d345dc32..657893b0f 100644 --- a/tests/camel-kamelets-itest/src/test/resources/avro/avro-data-type.it.yaml +++ b/tests/camel-kamelets-itest/src/test/resources/avro/avro-data-type.it.yaml @@ -23,6 +23,9 @@ actions: - camel: jbang: run: + args: + - "--port" + - "${avro.webhook.server.port}" integration: file: "avro/avro-x-struct-sink-pipe.yaml" - camel: @@ -32,6 +35,8 @@ actions: file: "avro/avro-binary-source-pipe.yaml" systemProperties: properties: + - name: "http.sink.url" + value: "http://localhost:${avro.webhook.server.port}/user" - name: "input" value: | { \"id\": \"${uuid}\", \"firstname\": \"Sheldon\", \"lastname\": \"Cooper\", \"age\": 28 } diff --git a/tests/camel-kamelets-itest/src/test/resources/avro/avro-serdes-action.it.yaml b/tests/camel-kamelets-itest/src/test/resources/avro/avro-serdes-action.it.yaml index 3bc1dfa16..9548ccaf0 100644 --- a/tests/camel-kamelets-itest/src/test/resources/avro/avro-serdes-action.it.yaml +++ b/tests/camel-kamelets-itest/src/test/resources/avro/avro-serdes-action.it.yaml @@ -23,6 +23,9 @@ actions: - camel: jbang: run: + args: + - "--port" + - "${avro.webhook.server.port}" integration: file: "avro/avro-deserialize-pipe.yaml" - camel: @@ -32,6 +35,8 @@ actions: file: "avro/avro-serialize-pipe.yaml" systemProperties: properties: + - name: "http.sink.url" + value: "http://localhost:${avro.webhook.server.port}/user" - name: "input" value: | { \"id\": \"${uuid}\", \"firstname\": \"Sheldon\", \"lastname\": \"Cooper\", \"age\": 28 } diff --git a/tests/camel-kamelets-itest/src/test/resources/avro/avro-serialize-pipe.yaml b/tests/camel-kamelets-itest/src/test/resources/avro/avro-serialize-pipe.yaml index 0c666689c..021593f72 100644 --- a/tests/camel-kamelets-itest/src/test/resources/avro/avro-serialize-pipe.yaml +++ b/tests/camel-kamelets-itest/src/test/resources/avro/avro-serialize-pipe.yaml @@ -49,4 +49,4 @@ spec: properties: showHeaders: true sink: - uri: http://localhost:8080/user + uri: "{{http.sink.url}}" diff --git a/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-to-http.it.yaml b/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-to-http.it.yaml index d467194cb..13f815e8e 100644 --- a/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-to-http.it.yaml +++ b/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-to-http.it.yaml @@ -50,7 +50,7 @@ actions: file: "aws/s3/application.properties" properties: - name: http.sink.url - value: "http://localhost:${http.server.port}/incoming" + value: "http://localhost:${aws.sink.server.port}/incoming" # Publish event - send: @@ -64,7 +64,7 @@ actions: # Verify Http request - http: - server: "httpServer" + server: "awsSinkServer" receiveRequest: POST: path: "/incoming" diff --git a/tests/camel-kamelets-itest/src/test/resources/citrus-application.properties b/tests/camel-kamelets-itest/src/test/resources/citrus-application.properties index 63df8a9ce..60735f11c 100644 --- a/tests/camel-kamelets-itest/src/test/resources/citrus-application.properties +++ b/tests/camel-kamelets-itest/src/test/resources/citrus-application.properties @@ -1,5 +1,19 @@ -# Configure endpoints used in tests (e.g. generic Http server) -citrus.java.config=EndpointAutoConfiguration +# +# 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. +# citrus.file.encoding=UTF-8 @@ -11,16 +25,13 @@ citrus.cluster.type=local citrus.camel.jbang.max.attempts=10 # Camel JBang version (should align with version used in pom.xml) -citrus.camel.jbang.version=4.9.0 -# Kamelets version (should point to the next snapshot release version) -citrus.camel.jbang.kamelets.version=4.10.0-SNAPSHOT - -# Tests should use local Kamelets -citrus.camel.jbang.kamelets.local.dir=../../../kamelets +citrus.camel.jbang.version=4.11.0 +# Kamelets version (should point to the current snapshot release version) +citrus.camel.jbang.kamelets.version=4.12.0-SNAPSHOT # Enable dump of Camel JBang integration output citrus.camel.jbang.dump.integration.output=true # Use general registry mirror for Docker images (e.g. Testcontainers) citrus.testcontainers.registry.mirror=mirror.gcr.io -citrus.testcontainers.registry.mirror.enabled=true +citrus.testcontainers.registry.mirror.enabled=false diff --git a/tests/camel-kamelets-itest/src/test/resources/junit-platform.properties b/tests/camel-kamelets-itest/src/test/resources/junit-platform.properties new file mode 100644 index 000000000..06fe1e11b --- /dev/null +++ b/tests/camel-kamelets-itest/src/test/resources/junit-platform.properties @@ -0,0 +1,19 @@ +# +# 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. +# + +junit.jupiter.execution.parallel.enabled = true +junit.jupiter.execution.parallel.mode.classes.default = concurrent diff --git a/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-router-pipe.it.yaml b/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-router-pipe.it.yaml index 5d3a79a07..d3289c0ff 100644 --- a/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-router-pipe.it.yaml +++ b/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-router-pipe.it.yaml @@ -43,6 +43,9 @@ actions: - camel: jbang: run: + args: + - "--port" + - "${kafka.webhook.server.port}" integration: file: "kafka/kafka-router-pipe.yaml" systemProperties: @@ -50,7 +53,7 @@ actions: # Invoke Http webhook endpoint - http: - client: "http://localhost:8080/messages" + client: "http://localhost:${kafka.webhook.server.port}/messages" sendRequest: fork: true GET: @@ -72,7 +75,7 @@ actions: # Verify Http webhook response - http: - client: "http://localhost:8080/messages" + client: "http://localhost:${kafka.webhook.server.port}/messages" receiveResponse: response: status: 200 diff --git a/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-source-pipe.it.yaml b/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-source-pipe.it.yaml index c1ec199fb..a432d9506 100644 --- a/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-source-pipe.it.yaml +++ b/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-source-pipe.it.yaml @@ -49,7 +49,7 @@ actions: file: "kafka/application.properties" properties: - name: http.sink.url - value: "http://localhost:${http.server.port}/result" + value: "http://localhost:${kafka.sink.server.port}/result" # Verify topic subscription - camel: @@ -73,7 +73,7 @@ actions: # Verify Http request - http: - server: "httpServer" + server: "kafkaSinkServer" receiveRequest: POST: path: "/result" diff --git a/tests/camel-kamelets-itest/src/test/resources/protobuf/protobuf-binary-source-pipe.yaml b/tests/camel-kamelets-itest/src/test/resources/protobuf/protobuf-binary-source-pipe.yaml index 419b2aa9e..7d2c4b592 100644 --- a/tests/camel-kamelets-itest/src/test/resources/protobuf/protobuf-binary-source-pipe.yaml +++ b/tests/camel-kamelets-itest/src/test/resources/protobuf/protobuf-binary-source-pipe.yaml @@ -57,4 +57,4 @@ spec: properties: format: "protobuf-binary" sink: - uri: http://localhost:8080/user + uri: "{{http.sink.url}}" diff --git a/tests/camel-kamelets-itest/src/test/resources/protobuf/protobuf-data-type.it.yaml b/tests/camel-kamelets-itest/src/test/resources/protobuf/protobuf-data-type.it.yaml index 4660e6893..0982c7da3 100644 --- a/tests/camel-kamelets-itest/src/test/resources/protobuf/protobuf-data-type.it.yaml +++ b/tests/camel-kamelets-itest/src/test/resources/protobuf/protobuf-data-type.it.yaml @@ -23,6 +23,9 @@ actions: - camel: jbang: run: + args: + - "--port" + - "${protobuf.webhook.server.port}" integration: file: "protobuf/protobuf-x-struct-sink-pipe.yaml" - camel: @@ -32,6 +35,8 @@ actions: file: "protobuf/protobuf-binary-source-pipe.yaml" systemProperties: properties: + - name: "http.sink.url" + value: "http://localhost:${protobuf.webhook.server.port}/user" - name: "input" value: | { \"id\": \"${uuid}\", \"firstname\": \"Sheldon\", \"lastname\": \"Cooper\", \"age\": 28 } diff --git a/tests/camel-kamelets-itest/src/test/resources/protobuf/protobuf-serdes-action.it.yaml b/tests/camel-kamelets-itest/src/test/resources/protobuf/protobuf-serdes-action.it.yaml index 35ddc2b22..5a40c8ca6 100644 --- a/tests/camel-kamelets-itest/src/test/resources/protobuf/protobuf-serdes-action.it.yaml +++ b/tests/camel-kamelets-itest/src/test/resources/protobuf/protobuf-serdes-action.it.yaml @@ -23,6 +23,9 @@ actions: - camel: jbang: run: + args: + - "--port" + - "${protobuf.webhook.server.port}" integration: file: "protobuf/protobuf-deserialize-pipe.yaml" - camel: @@ -32,6 +35,8 @@ actions: file: "protobuf/protobuf-serialize-pipe.yaml" systemProperties: properties: + - name: "http.sink.url" + value: "http://localhost:${protobuf.webhook.server.port}/user" - name: "input" value: | { \"id\": \"${uuid}\", \"firstname\": \"Sheldon\", \"lastname\": \"Cooper\", \"age\": 28 } diff --git a/tests/camel-kamelets-itest/src/test/resources/protobuf/protobuf-serialize-pipe.yaml b/tests/camel-kamelets-itest/src/test/resources/protobuf/protobuf-serialize-pipe.yaml index 7ddece308..1c28b5d83 100644 --- a/tests/camel-kamelets-itest/src/test/resources/protobuf/protobuf-serialize-pipe.yaml +++ b/tests/camel-kamelets-itest/src/test/resources/protobuf/protobuf-serialize-pipe.yaml @@ -56,4 +56,4 @@ spec: properties: showHeaders: true sink: - uri: http://localhost:8080/user + uri: "{{http.sink.url}}"