This is an automated email from the ASF dual-hosted git repository. jamesnetherton pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push: new e32fa2d97e Add DataSet extension e32fa2d97e is described below commit e32fa2d97e5149f944144375c5693b2bc0b2262a Author: James Netherton <jamesnether...@gmail.com> AuthorDate: Wed Jul 20 09:05:42 2022 +0100 Add DataSet extension Fixes #3926 --- catalog/pom.xml | 13 + .../ROOT/examples/components/dataset-test.yml | 13 + docs/modules/ROOT/examples/components/dataset.yml | 13 + docs/modules/ROOT/nav.adoc | 1 + .../ROOT/pages/reference/extensions/dataset.adoc | 40 +++ extensions/dataset/deployment/pom.xml | 67 ++++ .../dataset/deployment/DataSetProcessor.java | 30 ++ extensions/dataset/pom.xml | 39 ++ extensions/dataset/runtime/pom.xml | 105 ++++++ .../main/resources/META-INF/quarkus-extension.yaml | 31 ++ extensions/pom.xml | 1 + integration-test-groups/foundation/dataset/pom.xml | 163 +++++++++ .../component/dataset/it/CustomDataSet.java | 64 ++++ .../component/dataset/it/DataSetProducers.java | 140 ++++++++ .../component/dataset/it/DataSetResource.java | 391 +++++++++++++++++++++ .../component/dataset/it/DataSetRoutes.java | 75 ++++ .../src/main/resources/application.properties | 17 + .../quarkus/component/dataset/it/DataSetIT.java | 24 ++ .../quarkus/component/dataset/it/DataSetTest.java | 170 +++++++++ integration-test-groups/foundation/pom.xml | 1 + integration-tests/foundation-grouped/pom.xml | 34 ++ poms/bom/pom.xml | 15 + poms/bom/src/main/generated/flattened-full-pom.xml | 15 + .../src/main/generated/flattened-reduced-pom.xml | 15 + .../generated/flattened-reduced-verbose-pom.xml | 15 + 25 files changed, 1492 insertions(+) diff --git a/catalog/pom.xml b/catalog/pom.xml index 070e149c31..0d9c0c9edf 100644 --- a/catalog/pom.xml +++ b/catalog/pom.xml @@ -1007,6 +1007,19 @@ </exclusion> </exclusions> </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-dataset</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>*</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-datasonnet</artifactId> diff --git a/docs/modules/ROOT/examples/components/dataset-test.yml b/docs/modules/ROOT/examples/components/dataset-test.yml new file mode 100644 index 0000000000..0d5a0b4c0b --- /dev/null +++ b/docs/modules/ROOT/examples/components/dataset-test.yml @@ -0,0 +1,13 @@ +# Do not edit directly! +# This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page +cqArtifactId: camel-quarkus-dataset +cqArtifactIdBase: dataset +cqNativeSupported: true +cqStatus: Stable +cqDeprecated: false +cqJvmSince: 2.11.0 +cqNativeSince: 2.11.0 +cqCamelPartName: dataset-test +cqCamelPartTitle: DataSet Test +cqCamelPartDescription: Extends the mock component by pulling messages from another endpoint on startup to set the expected message bodies. +cqExtensionPageTitle: Dataset diff --git a/docs/modules/ROOT/examples/components/dataset.yml b/docs/modules/ROOT/examples/components/dataset.yml new file mode 100644 index 0000000000..348c40faf6 --- /dev/null +++ b/docs/modules/ROOT/examples/components/dataset.yml @@ -0,0 +1,13 @@ +# Do not edit directly! +# This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page +cqArtifactId: camel-quarkus-dataset +cqArtifactIdBase: dataset +cqNativeSupported: true +cqStatus: Stable +cqDeprecated: false +cqJvmSince: 2.11.0 +cqNativeSince: 2.11.0 +cqCamelPartName: dataset +cqCamelPartTitle: Dataset +cqCamelPartDescription: Provide data for load and soak testing of your Camel application. +cqExtensionPageTitle: Dataset diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc index f71f6b9b75..5bc932dc94 100644 --- a/docs/modules/ROOT/nav.adoc +++ b/docs/modules/ROOT/nav.adoc @@ -98,6 +98,7 @@ *** xref:reference/extensions/dns.adoc[DNS] *** xref:reference/extensions/dataformat.adoc[Data Format] *** xref:reference/extensions/datasonnet.adoc[DataSonnet] +*** xref:reference/extensions/dataset.adoc[Dataset] *** xref:reference/extensions/debezium-mongodb.adoc[Debezium MongoDB Connector] *** xref:reference/extensions/debezium-mysql.adoc[Debezium MySQL Connector] *** xref:reference/extensions/debezium-postgres.adoc[Debezium PostgresSQL Connector] diff --git a/docs/modules/ROOT/pages/reference/extensions/dataset.adoc b/docs/modules/ROOT/pages/reference/extensions/dataset.adoc new file mode 100644 index 0000000000..da0f7a36e4 --- /dev/null +++ b/docs/modules/ROOT/pages/reference/extensions/dataset.adoc @@ -0,0 +1,40 @@ +// Do not edit directly! +// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page += Dataset +:linkattrs: +:cq-artifact-id: camel-quarkus-dataset +:cq-native-supported: true +:cq-status: Stable +:cq-status-deprecation: Stable +:cq-description: Provide data for load and soak testing of your Camel application. +:cq-deprecated: false +:cq-jvm-since: 2.11.0 +:cq-native-since: 2.11.0 + +[.badges] +[.badge-key]##JVM since##[.badge-supported]##2.11.0## [.badge-key]##Native since##[.badge-supported]##2.11.0## + +Provide data for load and soak testing of your Camel application. + +== What's inside + +* xref:{cq-camel-components}::dataset-component.adoc[Dataset component], URI syntax: `dataset:name` +* xref:{cq-camel-components}::dataset-test-component.adoc[DataSet Test component], URI syntax: `dataset-test:name` + +Please refer to the above links for usage and configuration details. + +== Maven coordinates + +https://code.quarkus.io/?extension-search=camel-quarkus-dataset[Create a new project with this extension on code.quarkus.io, window="_blank"] + +Or add the coordinates to your existing project: + +[source,xml] +---- +<dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-dataset</artifactId> +</dependency> +---- + +Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications. diff --git a/extensions/dataset/deployment/pom.xml b/extensions/dataset/deployment/pom.xml new file mode 100644 index 0000000000..e037bb838b --- /dev/null +++ b/extensions/dataset/deployment/pom.xml @@ -0,0 +1,67 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-dataset-parent</artifactId> + <version>2.11.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-dataset-deployment</artifactId> + <name>Camel Quarkus :: Dataset :: Deployment</name> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-core-deployment</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-mock-deployment</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-dataset</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <annotationProcessorPaths> + <path> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-extension-processor</artifactId> + <version>${quarkus.version}</version> + </path> + </annotationProcessorPaths> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/extensions/dataset/deployment/src/main/java/org/apache/camel/quarkus/component/dataset/deployment/DataSetProcessor.java b/extensions/dataset/deployment/src/main/java/org/apache/camel/quarkus/component/dataset/deployment/DataSetProcessor.java new file mode 100644 index 0000000000..23b2f6ec33 --- /dev/null +++ b/extensions/dataset/deployment/src/main/java/org/apache/camel/quarkus/component/dataset/deployment/DataSetProcessor.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.dataset.deployment; + +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.FeatureBuildItem; + +class DataSetProcessor { + + private static final String FEATURE = "camel-dataset"; + + @BuildStep + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); + } +} diff --git a/extensions/dataset/pom.xml b/extensions/dataset/pom.xml new file mode 100644 index 0000000000..51d58fb2dd --- /dev/null +++ b/extensions/dataset/pom.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-extensions</artifactId> + <version>2.11.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-dataset-parent</artifactId> + <name>Camel Quarkus :: Dataset</name> + <packaging>pom</packaging> + + <modules> + <module>deployment</module> + <module>runtime</module> + </modules> +</project> diff --git a/extensions/dataset/runtime/pom.xml b/extensions/dataset/runtime/pom.xml new file mode 100644 index 0000000000..e1cd1f8421 --- /dev/null +++ b/extensions/dataset/runtime/pom.xml @@ -0,0 +1,105 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-dataset-parent</artifactId> + <version>2.11.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-dataset</artifactId> + <name>Camel Quarkus :: Dataset :: Runtime</name> + <description>Provide data for load and soak testing of your Camel application.</description> + + <properties> + <camel.quarkus.jvmSince>2.11.0</camel.quarkus.jvmSince> + <camel.quarkus.nativeSince>2.11.0</camel.quarkus.nativeSince> + </properties> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-core</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-mock</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-dataset</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-extension-maven-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <annotationProcessorPaths> + <path> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-extension-processor</artifactId> + <version>${quarkus.version}</version> + </path> + </annotationProcessorPaths> + </configuration> + </plugin> + </plugins> + </build> + + + <profiles> + <profile> + <id>full</id> + <activation> + <property> + <name>!quickly</name> + </property> + </activation> + <build> + <plugins> + <plugin> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-maven-plugin</artifactId> + <executions> + <execution> + <id>update-extension-doc-page</id> + <goals> + <goal>update-extension-doc-page</goal> + </goals> + <phase>process-classes</phase> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + </profiles> +</project> diff --git a/extensions/dataset/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/dataset/runtime/src/main/resources/META-INF/quarkus-extension.yaml new file mode 100644 index 0000000000..8f547c30bf --- /dev/null +++ b/extensions/dataset/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -0,0 +1,31 @@ +# +# 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. +# + +# This is a generated file. Do not edit directly! +# To re-generate, run the following command from the top level directory: +# +# mvn -N cq:update-quarkus-metadata +# +--- +name: "Camel Dataset" +description: "Provide data for load and soak testing of your Camel application" +metadata: + guide: "https://camel.apache.org/camel-quarkus/latest/reference/extensions/dataset.html" + categories: + - "integration" + status: + - "stable" diff --git a/extensions/pom.xml b/extensions/pom.xml index 77d0e3810a..e7758929e2 100644 --- a/extensions/pom.xml +++ b/extensions/pom.xml @@ -83,6 +83,7 @@ <module>csimple</module> <module>csv</module> <module>dataformat</module> + <module>dataset</module> <module>datasonnet</module> <module>debezium-mongodb</module> <module>debezium-mysql</module> diff --git a/integration-test-groups/foundation/dataset/pom.xml b/integration-test-groups/foundation/dataset/pom.xml new file mode 100644 index 0000000000..13a7f04520 --- /dev/null +++ b/integration-test-groups/foundation/dataset/pom.xml @@ -0,0 +1,163 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-build-parent-it</artifactId> + <version>2.11.0-SNAPSHOT</version> + <relativePath>../../../poms/build-parent-it/pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-integration-test-dataset</artifactId> + <name>Camel Quarkus :: Integration Tests :: Dataset</name> + <description>Integration tests for Camel Quarkus Dataset extension</description> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-dataset</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-direct</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-file</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-seda</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-resteasy</artifactId> + </dependency> + + <!-- test dependencies --> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-junit5</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>io.rest-assured</groupId> + <artifactId>rest-assured</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + + <profiles> + <profile> + <id>native</id> + <activation> + <property> + <name>native</name> + </property> + </activation> + <properties> + <quarkus.package.type>native</quarkus.package.type> + </properties> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-failsafe-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>integration-test</goal> + <goal>verify</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + <profile> + <id>virtualDependencies</id> + <activation> + <property> + <name>!noVirtualDependencies</name> + </property> + </activation> + <dependencies> + <!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory --> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-dataset-deployment</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>*</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-direct-deployment</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>*</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-file-deployment</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>*</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-seda-deployment</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>*</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> + </dependencies> + </profile> + </profiles> + +</project> diff --git a/integration-test-groups/foundation/dataset/src/main/java/org/apache/camel/quarkus/component/dataset/it/CustomDataSet.java b/integration-test-groups/foundation/dataset/src/main/java/org/apache/camel/quarkus/component/dataset/it/CustomDataSet.java new file mode 100644 index 0000000000..26379c6420 --- /dev/null +++ b/integration-test-groups/foundation/dataset/src/main/java/org/apache/camel/quarkus/component/dataset/it/CustomDataSet.java @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.dataset.it; + +import java.util.Map; + +import org.apache.camel.Exchange; +import org.apache.camel.Message; +import org.apache.camel.component.dataset.DataSetEndpoint; +import org.apache.camel.component.dataset.DataSetSupport; + +public class CustomDataSet extends DataSetSupport { + @Override + public void assertMessageExpected(DataSetEndpoint dataSetEndpoint, Exchange expected, Exchange actual, long index) { + Message expectedMessage = expected.getMessage(); + Message actualMessage = actual.getMessage(); + + String expectedBody = expectedMessage.getBody(String.class); + String actualBody = actualMessage.getBody(String.class); + if (!expectedBody.equals(actualBody)) { + throw new AssertionError(String.format("Expected body %s but got %s", expectedBody, actualBody)); + } + + String expectedHeader = expectedMessage.getHeader("foo", String.class); + if (expectedHeader == null) { + throw new AssertionError("Expected header foo is null"); + } + + String actualHeader = actualMessage.getHeader("foo", String.class); + if (actualHeader == null) { + throw new AssertionError("Actual header foo is null"); + } + + if (!expectedHeader.equals(actualHeader)) { + throw new AssertionError(String.format("Expected header foo to equal %s but got %s", expectedHeader, actualHeader)); + } + } + + @Override + protected Object createMessageBody(long messageIndex) { + // Custom OutputTransformer processor will append ' World' to the body + // See DataSetProducers.customDataSet + return "Hello"; + } + + @Override + protected void populateDefaultHeaders(Map<String, Object> map) { + map.put("foo", "bar"); + } +} diff --git a/integration-test-groups/foundation/dataset/src/main/java/org/apache/camel/quarkus/component/dataset/it/DataSetProducers.java b/integration-test-groups/foundation/dataset/src/main/java/org/apache/camel/quarkus/component/dataset/it/DataSetProducers.java new file mode 100644 index 0000000000..ee2e8bdeff --- /dev/null +++ b/integration-test-groups/foundation/dataset/src/main/java/org/apache/camel/quarkus/component/dataset/it/DataSetProducers.java @@ -0,0 +1,140 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.dataset.it; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.LinkedList; +import java.util.List; + +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.inject.Disposes; +import javax.inject.Named; + +import org.apache.camel.Exchange; +import org.apache.camel.Message; +import org.apache.camel.Processor; +import org.apache.camel.component.dataset.FileDataSet; +import org.apache.camel.component.dataset.ListDataSet; +import org.apache.camel.component.dataset.SimpleDataSet; + +@ApplicationScoped +public class DataSetProducers { + + @Named("customDataSet") + public CustomDataSet customDataSet() { + CustomDataSet customDataSet = new CustomDataSet(); + customDataSet.setOutputTransformer(new Processor() { + @Override + public void process(Exchange exchange) throws Exception { + Message message = exchange.getMessage(); + String body = message.getBody(String.class); + // Sets the body to 'Hello World' + message.setBody(body + " World"); + } + }); + return customDataSet; + } + + @Named("simpleDataSet") + public SimpleDataSet simpleDataSet() { + return new SimpleDataSet(); + } + + @Named("simpleDataSetForConsumer") + public SimpleDataSet simpleDataSetForConsumer() { + return new SimpleDataSet(); + } + + @Named("simpleDataSetForException") + public SimpleDataSet simpleDataSetForException() { + return new SimpleDataSet(1); + } + + @Named("simpleDataSetWithIndex") + public SimpleDataSet simpleDataSetWithIndex() { + return new SimpleDataSet(); + } + + @Named("simpleDataSetIndexOff") + public SimpleDataSet simpleDataSetIndexOff() { + return new SimpleDataSet(); + } + + @Named("simpleDataSetIndexLenient") + public SimpleDataSet simpleDataSetIndexLenient() { + return new SimpleDataSet(); + } + + @Named("simpleDataSetIndexStrict") + public SimpleDataSet simpleDataSetIndexStrict() { + return new SimpleDataSet(); + } + + @Named("simpleDataSetIndexStrictWithoutHeader") + public SimpleDataSet simpleDataSetIndexStrictWithoutHeader() { + return new SimpleDataSet(); + } + + @Named("listDataSet") + public ListDataSet listDataSet() { + List<Object> bodies = new LinkedList<>(); + bodies.add("Hello"); + bodies.add("World"); + return new ListDataSet(bodies); + } + + @Named("listDataSetForConsumer") + public ListDataSet listDataSetForConsumer() { + List<Object> bodies = new LinkedList<>(); + bodies.add("Hello"); + bodies.add("World"); + return new ListDataSet(bodies); + } + + @Named("fileDataSet") + public FileDataSet fileDataSet() throws IOException { + Path path = Files.createTempFile("fileDataSet", ".txt"); + Files.write(path, "Hello World".getBytes(StandardCharsets.UTF_8)); + return new FileDataSet(path.toFile()); + } + + @Named("fileDataSetDelimited") + public FileDataSet fileDataSetDelimited() throws IOException { + Path path = Files.createTempFile("fileDataSetDelimited", ".txt"); + Files.write(path, "Hello,World".getBytes(StandardCharsets.UTF_8)); + return new FileDataSet(path.toFile(), ","); + } + + @Named("preloadedDataSet") + public SimpleDataSet preloadedDataSet() { + return new SimpleDataSet(); + } + + @Named("sedaDataSet") + public SimpleDataSet sedaDataSet() { + return new SimpleDataSet(); + } + + void disposeFileDataSet(@Disposes FileDataSet fileDataSet) throws IOException { + File file = fileDataSet.getSourceFile(); + Files.deleteIfExists(file.toPath()); + } +} diff --git a/integration-test-groups/foundation/dataset/src/main/java/org/apache/camel/quarkus/component/dataset/it/DataSetResource.java b/integration-test-groups/foundation/dataset/src/main/java/org/apache/camel/quarkus/component/dataset/it/DataSetResource.java new file mode 100644 index 0000000000..f421ea5ff1 --- /dev/null +++ b/integration-test-groups/foundation/dataset/src/main/java/org/apache/camel/quarkus/component/dataset/it/DataSetResource.java @@ -0,0 +1,391 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.dataset.it; + +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Response; + +import org.apache.camel.CamelContext; +import org.apache.camel.Exchange; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.dataset.DataSetEndpoint; +import org.apache.camel.component.dataset.DataSetTestEndpoint; +import org.apache.camel.component.dataset.FileDataSet; +import org.apache.camel.component.dataset.ListDataSet; +import org.apache.camel.component.dataset.SimpleDataSet; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.support.CamelContextHelper; + +@Path("/dataset") +@ApplicationScoped +public class DataSetResource { + @Inject + ProducerTemplate producerTemplate; + + @Inject + CamelContext context; + + @GET + @Path("/simple") + public void dataSetSimple(@QueryParam("useIndexHeader") boolean useIndexHeader) throws InterruptedException { + String dataSetName = useIndexHeader ? "simpleDataSetWithIndex" : "simpleDataSet"; + SimpleDataSet simpleDataSet = CamelContextHelper.lookup(context, dataSetName, SimpleDataSet.class); + + DataSetEndpoint endpoint = context.getEndpoint("dataset:" + dataSetName + "?minRate=50", DataSetEndpoint.class); + endpoint.expectedMessageCount((int) simpleDataSet.getSize()); + + for (int i = 0; i < simpleDataSet.getSize(); i++) { + if (useIndexHeader) { + producerTemplate.sendBodyAndHeader("direct:simpleDataSetWithIndex", simpleDataSet.getDefaultBody(), + Exchange.DATASET_INDEX, i); + } else { + producerTemplate.sendBody("direct:simpleDataSet", simpleDataSet.getDefaultBody()); + } + } + + try { + endpoint.assertIsSatisfied(5000); + } finally { + endpoint.reset(); + } + } + + @GET + @Path("/simple/exception") + public Response simpleDataSetAssertionException() throws InterruptedException { + DataSetEndpoint endpoint = context.getEndpoint("dataset:simpleDataSetForException", DataSetEndpoint.class); + + producerTemplate.sendBody("direct:simpleDataSetForException", "invalid payload"); + + try { + endpoint.assertIsSatisfied(5000); + } catch (Throwable t) { + if (t instanceof AssertionError) { + return Response.ok().build(); + } else { + return Response.serverError().build(); + } + } finally { + endpoint.reset(); + } + + return Response.serverError().build(); + } + + @GET + @Path("/simple/consumer") + public void dataSetSimpleConsumer() throws Exception { + MockEndpoint endpoint = context.getEndpoint("mock:simpleDataSetResult", MockEndpoint.class); + endpoint.expectedBodiesReceived("<hello>world!</hello>"); + + context.getRouteController().startRoute("simple"); + try { + endpoint.assertIsSatisfied(5000); + } finally { + context.getRouteController().stopRoute("simple"); + endpoint.reset(); + } + } + + @GET + @Path("/list") + public void dataSetList() throws InterruptedException { + ListDataSet listDataSet = CamelContextHelper.lookup(context, "listDataSet", ListDataSet.class); + DataSetEndpoint endpoint = context.getEndpoint("dataset:listDataSet", DataSetEndpoint.class); + endpoint.expectedMessageCount((int) listDataSet.getSize()); + + producerTemplate.sendBodyAndHeader("direct:listDataSet", "Hello", Exchange.DATASET_INDEX, 0); + producerTemplate.sendBodyAndHeader("direct:listDataSet", "World", Exchange.DATASET_INDEX, 1); + + try { + endpoint.assertIsSatisfied(5000); + } finally { + endpoint.reset(); + } + } + + @GET + @Path("/list/consumer") + public void dataSetListConsumer() throws Exception { + MockEndpoint endpoint = context.getEndpoint("mock:listDataSetResult", MockEndpoint.class); + endpoint.expectedBodiesReceived("Hello", "World"); + + context.getRouteController().startRoute("list"); + try { + endpoint.assertIsSatisfied(5000); + } finally { + context.getRouteController().stopRoute("list"); + endpoint.reset(); + } + } + + @GET + @Path("/file") + public void dataSetFile() throws InterruptedException { + FileDataSet fileDataSet = CamelContextHelper.lookup(context, "fileDataSet", FileDataSet.class); + DataSetEndpoint endpoint = context.getEndpoint("dataset:fileDataSet", DataSetEndpoint.class); + endpoint.expectedMessageCount((int) fileDataSet.getSize()); + + producerTemplate.sendBodyAndHeader("direct:fileDataSet", "Hello World\n", Exchange.DATASET_INDEX, 0); + + try { + endpoint.assertIsSatisfied(5000); + } finally { + endpoint.reset(); + } + } + + @GET + @Path("/file/delimited") + public void dataSetFileDelimited() throws InterruptedException { + FileDataSet fileDataSet = CamelContextHelper.lookup(context, "fileDataSetDelimited", FileDataSet.class); + DataSetEndpoint endpoint = context.getEndpoint("dataset:fileDataSetDelimited", DataSetEndpoint.class); + endpoint.expectedMessageCount((int) fileDataSet.getSize()); + + producerTemplate.sendBodyAndHeader("direct:fileDataSetDelimited", "Hello", Exchange.DATASET_INDEX, 0); + producerTemplate.sendBodyAndHeader("direct:fileDataSetDelimited", "World", Exchange.DATASET_INDEX, 1); + + try { + endpoint.assertIsSatisfied(5000); + } finally { + endpoint.reset(); + } + } + + @GET + @Path("/file/consumer") + public void dataSetFileConsumer() throws Exception { + MockEndpoint endpoint = context.getEndpoint("mock:fileDataSetResult", MockEndpoint.class); + endpoint.expectedBodiesReceived("Hello World\n"); + + context.getRouteController().startRoute("file"); + try { + endpoint.assertIsSatisfied(5000); + } finally { + context.getRouteController().stopRoute("file"); + endpoint.reset(); + } + } + + @GET + @Path("/custom") + public void dataSetCustom() throws Exception { + context.getRouteController().startRoute("custom"); + + CustomDataSet customDataSet = CamelContextHelper.lookup(context, "customDataSet", CustomDataSet.class); + DataSetEndpoint endpoint = context.getEndpoint("dataset:customDataSet", DataSetEndpoint.class); + endpoint.setExpectedMessageCount((int) customDataSet.getSize()); + + try { + endpoint.assertIsSatisfied(5000); + } finally { + context.getRouteController().stopRoute("custom"); + endpoint.reset(); + } + } + + @GET + @Path("/simple/index/off") + public void dataSetIndexOff() throws InterruptedException { + SimpleDataSet simpleDataSet = CamelContextHelper.lookup(context, "simpleDataSetIndexOff", SimpleDataSet.class); + DataSetEndpoint endpoint = context.getEndpoint("dataset:simpleDataSetIndexOff?dataSetIndex=off", DataSetEndpoint.class); + endpoint.setExpectedMessageCount((int) simpleDataSet.getSize()); + + for (int i = 0; i < simpleDataSet.getSize(); i++) { + if (0 == i % 2) { + producerTemplate.sendBodyAndHeader("direct:simpleDataSetIndexOff", simpleDataSet.getDefaultBody(), + Exchange.DATASET_INDEX, i - 1); + } else { + producerTemplate.sendBody("direct:simpleDataSetIndexOff", simpleDataSet.getDefaultBody()); + } + } + + try { + endpoint.assertIsSatisfied(5000); + } finally { + endpoint.reset(); + } + } + + @GET + @Path("/simple/index/lenient") + public void dataSetIndexLenient() throws InterruptedException { + SimpleDataSet simpleDataSet = CamelContextHelper.lookup(context, "simpleDataSetIndexLenient", SimpleDataSet.class); + DataSetEndpoint endpoint = context.getEndpoint("dataset:simpleDataSetIndexLenient?dataSetIndex=lenient", + DataSetEndpoint.class); + endpoint.setExpectedMessageCount((int) simpleDataSet.getSize()); + + for (int i = 0; i < simpleDataSet.getSize(); i++) { + if (0 == i % 2) { + producerTemplate.sendBodyAndHeader("direct:simpleDataSetIndexLenient", simpleDataSet.getDefaultBody(), + Exchange.DATASET_INDEX, i); + } else { + producerTemplate.sendBody("direct:simpleDataSetIndexLenient", simpleDataSet.getDefaultBody()); + } + } + + try { + endpoint.assertIsSatisfied(5000); + } finally { + endpoint.reset(); + } + } + + @GET + @Path("/simple/index/strict") + public Response dataSetIndexStrict(@QueryParam("useIndexHeader") boolean useIndexHeader) throws InterruptedException { + String dataSet = useIndexHeader ? "simpleDataSetIndexStrict" : "simpleDataSetIndexStrictWithoutHeader"; + SimpleDataSet simpleDataSet = CamelContextHelper.lookup(context, dataSet, SimpleDataSet.class); + DataSetEndpoint endpoint = context.getEndpoint("dataset:" + dataSet + "?dataSetIndex=strict", DataSetEndpoint.class); + endpoint.setExpectedMessageCount((int) simpleDataSet.getSize()); + + for (int i = 0; i < simpleDataSet.getSize(); i++) { + if (useIndexHeader) { + producerTemplate.sendBodyAndHeader("direct:simpleDataSetIndexStrict", simpleDataSet.getDefaultBody(), + Exchange.DATASET_INDEX, i); + } else { + producerTemplate.sendBody("direct:simpleDataSetIndexStrictWithoutHeader", simpleDataSet.getDefaultBody()); + } + } + + try { + endpoint.assertIsSatisfied(5000); + } catch (Throwable t) { + return Response.serverError().entity(t.getMessage()).build(); + } finally { + endpoint.reset(); + } + + return Response.ok().build(); + } + + @GET + @Path("/preload") + public void dataSetPreloaded() throws Exception { + SimpleDataSet preloadedDataSet = CamelContextHelper.lookup(context, "preloadedDataSet", SimpleDataSet.class); + DataSetEndpoint endpoint = context.getEndpoint("dataset:preloadedDataSet?preloadSize=5", DataSetEndpoint.class); + endpoint.setExpectedMessageCount((int) preloadedDataSet.getSize()); + + context.getRouteController().startRoute("preload"); + try { + endpoint.assertIsSatisfied(5000); + } finally { + context.getRouteController().stopRoute("preload"); + endpoint.reset(); + } + + } + + @GET + @Path("/test/seda") + public void dataSetTestSeda() throws Exception { + producerTemplate.sendBody("seda:dataSetTestSeda", "Hello World"); + + // We do this here so that dataset-test can pull the messages sent to the seda endpoint + context.addRoutes(new RouteBuilder() { + public void configure() throws Exception { + from("direct:dataSetTestSeda").id("dataSetTestSeda") + .to("dataset-test:seda:dataSetTestSeda?timeout=0"); + } + }); + + DataSetTestEndpoint endpoint = context.getEndpoint("dataset-test:seda:dataSetTestSeda?timeout=0", + DataSetTestEndpoint.class); + endpoint.expectedMessageCount(1); + + producerTemplate.sendBody("direct:dataSetTestSeda", "Hello World"); + + try { + endpoint.assertIsSatisfied(5000); + } finally { + context.removeRoute("dataSetTestSeda"); + endpoint.reset(); + } + } + + @GET + @Path("/test/seda/any/order") + public void dataSetTestSedaAnyOrder() throws Exception { + producerTemplate.sendBody("seda:dataSetTestSedaAnyOrder", "Hello World"); + producerTemplate.sendBody("seda:dataSetTestSedaAnyOrder", "Bye World"); + + // We do this here so that dataset-test can pull the messages sent to the seda endpoint + context.addRoutes(new RouteBuilder() { + public void configure() throws Exception { + from("direct:dataSetTestSedaAnyOrder").id("dataSetTestSedaAnyOrder") + .to("dataset-test:seda:dataSetTestSedaAnyOrder?timeout=0&anyOrder=true"); + } + }); + + DataSetTestEndpoint endpoint = context.getEndpoint("dataset-test:seda:dataSetTestSedaAnyOrder?timeout=0&anyOrder=true", + DataSetTestEndpoint.class); + endpoint.expectedMessageCount(2); + + producerTemplate.sendBody("direct:dataSetTestSedaAnyOrder", "Bye World"); + producerTemplate.sendBody("direct:dataSetTestSedaAnyOrder", "Hello World"); + + try { + endpoint.assertIsSatisfied(5000); + } finally { + context.removeRoute("dataSetTestSedaAnyOrder"); + endpoint.reset(); + } + } + + @GET + @Path("/test/split") + public void dataSetTestSplit() throws Exception { + java.nio.file.Path path = Files.createTempFile("dataSetTestSplit", ".txt"); + Files.write(path, "Hello\nWorld\nBye\nWorld".getBytes(StandardCharsets.UTF_8)); + + context.addRoutes(new RouteBuilder() { + @Override + public void configure() throws Exception { + from("direct:dataSetTestSplit").id("dataSetTestSplit") + .toF("dataset-test:file:%s?noop=true&split=true&timeout=1000&fileName=%s", path.getParent(), + path.getFileName()); + } + }); + + DataSetTestEndpoint endpoint = context.getEndpoint( + String.format("dataset-test:file:%s?noop=true&split=true&timeout=1000&fileName=%s", path.getParent(), + path.getFileName()), + DataSetTestEndpoint.class); + endpoint.expectedMessageCount(4); + + producerTemplate.sendBody("direct:dataSetTestSplit", "Hello"); + producerTemplate.sendBody("direct:dataSetTestSplit", "World"); + producerTemplate.sendBody("direct:dataSetTestSplit", "Bye"); + producerTemplate.sendBody("direct:dataSetTestSplit", "World"); + + try { + endpoint.assertIsSatisfied(5000); + } finally { + context.removeRoute("dataSetTestSplit"); + endpoint.reset(); + Files.deleteIfExists(path); + } + } +} diff --git a/integration-test-groups/foundation/dataset/src/main/java/org/apache/camel/quarkus/component/dataset/it/DataSetRoutes.java b/integration-test-groups/foundation/dataset/src/main/java/org/apache/camel/quarkus/component/dataset/it/DataSetRoutes.java new file mode 100644 index 0000000000..47b9d30768 --- /dev/null +++ b/integration-test-groups/foundation/dataset/src/main/java/org/apache/camel/quarkus/component/dataset/it/DataSetRoutes.java @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.dataset.it; + +import org.apache.camel.builder.RouteBuilder; + +public class DataSetRoutes extends RouteBuilder { + @Override + public void configure() throws Exception { + from("direct:simpleDataSet") + .to("dataset:simpleDataSet?minRate=50"); + + from("direct:simpleDataSetWithIndex") + .to("dataset:simpleDataSetWithIndex?minRate=50"); + + from("direct:simpleDataSetForException") + .to("dataset:simpleDataSetForException"); + + from("dataset:simpleDataSetForConsumer").id("simple").autoStartup(false) + .to("mock:simpleDataSetResult"); + + from("direct:simpleDataSetIndexOff") + .to("dataset:simpleDataSetIndexOff?dataSetIndex=off"); + + from("direct:simpleDataSetIndexLenient") + .to("dataset:simpleDataSetIndexLenient?dataSetIndex=lenient"); + + from("direct:simpleDataSetIndexStrict") + .to("dataset:simpleDataSetIndexStrict?dataSetIndex=strict"); + + from("direct:simpleDataSetIndexStrictWithoutHeader") + .to("dataset:simpleDataSetIndexStrictWithoutHeader?dataSetIndex=strict"); + + from("direct:listDataSet") + .to("dataset:listDataSet"); + + from("dataset:listDataSetForConsumer").id("list").autoStartup(false) + .to("mock:listDataSetResult"); + + from("direct:fileDataSet") + .to("dataset:fileDataSet"); + + from("dataset:fileDataSet").id("file").autoStartup(false) + .to("mock:fileDataSetResult"); + + from("direct:fileDataSetDelimited") + .to("dataset:fileDataSetDelimited"); + + from("dataset:customDataSet").id("custom").autoStartup(false) + .to("direct:customDataSet"); + + from("direct:customDataSet") + .to("dataset:customDataSet"); + + from("dataset:preloadedDataSet?preloadSize=5").id("preload").autoStartup(false) + .to("seda:preloadedDataSet"); + + from("seda:preloadedDataSet") + .to("dataset:preloadedDataSet?preloadSize=5"); + } +} diff --git a/integration-test-groups/foundation/dataset/src/main/resources/application.properties b/integration-test-groups/foundation/dataset/src/main/resources/application.properties new file mode 100644 index 0000000000..0b2d774170 --- /dev/null +++ b/integration-test-groups/foundation/dataset/src/main/resources/application.properties @@ -0,0 +1,17 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- +camel.component.dataset-test.log = true \ No newline at end of file diff --git a/integration-test-groups/foundation/dataset/src/test/java/org/apache/camel/quarkus/component/dataset/it/DataSetIT.java b/integration-test-groups/foundation/dataset/src/test/java/org/apache/camel/quarkus/component/dataset/it/DataSetIT.java new file mode 100644 index 0000000000..efbf31d6af --- /dev/null +++ b/integration-test-groups/foundation/dataset/src/test/java/org/apache/camel/quarkus/component/dataset/it/DataSetIT.java @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.dataset.it; + +import io.quarkus.test.junit.QuarkusIntegrationTest; + +@QuarkusIntegrationTest +class DataSetIT extends DataSetTest { + +} diff --git a/integration-test-groups/foundation/dataset/src/test/java/org/apache/camel/quarkus/component/dataset/it/DataSetTest.java b/integration-test-groups/foundation/dataset/src/test/java/org/apache/camel/quarkus/component/dataset/it/DataSetTest.java new file mode 100644 index 0000000000..f0701caedb --- /dev/null +++ b/integration-test-groups/foundation/dataset/src/test/java/org/apache/camel/quarkus/component/dataset/it/DataSetTest.java @@ -0,0 +1,170 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.dataset.it; + +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +import static org.hamcrest.Matchers.containsString; + +@QuarkusTest +class DataSetTest { + + @ParameterizedTest + @ValueSource(booleans = { false, true }) + public void simpleDataSet(boolean useIndexHeader) { + RestAssured.given() + .queryParam("useIndexHeader", useIndexHeader) + .get("/dataset/simple") + .then() + .statusCode(204); + } + + @Test + public void simpleDataSetException() { + RestAssured.given() + .get("/dataset/simple/exception") + .then() + .statusCode(200); + } + + @Test + public void simpleDataSetConsumer() { + RestAssured.given() + .get("/dataset/simple/consumer") + .then() + .statusCode(204); + } + + @Test + public void listDataSet() { + RestAssured.given() + .get("/dataset/list") + .then() + .statusCode(204); + } + + @Test + public void listDataSetConsumer() { + RestAssured.given() + .get("/dataset/list/consumer") + .then() + .statusCode(204); + } + + @Test + public void fileDataSet() { + RestAssured.given() + .get("/dataset/file") + .then() + .statusCode(204); + } + + @Test + public void fileDataSetDelimited() { + RestAssured.given() + .get("/dataset/file/delimited") + .then() + .statusCode(204); + } + + @Test + public void fileDataSetConsumer() { + RestAssured.given() + .get("/dataset/file/consumer") + .then() + .statusCode(204); + } + + @Test + public void customDataSetProduceConsume() { + RestAssured.given() + .get("/dataset/custom") + .then() + .statusCode(204); + } + + @Test + public void indexOff() { + RestAssured.given() + .get("/dataset/simple/index/off") + .then() + .statusCode(204); + } + + @Test + public void indexLenient() { + RestAssured.given() + .get("/dataset/simple/index/lenient") + .then() + .statusCode(204); + } + + @Test + public void indexStrict() { + RestAssured.given() + .queryParam("useIndexHeader", true) + .get("/dataset/simple/index/strict") + .then() + .statusCode(200); + } + + @Test + public void indexStrictWithoutIndexHeader() { + RestAssured.given() + .queryParam("useIndexHeader", false) + .get("/dataset/simple/index/strict") + .then() + .statusCode(500) + .body(containsString("No 'CamelDataSetIndex' header available")); + } + + @Test + public void preload() { + RestAssured.given() + .get("/dataset/preload") + .then() + .statusCode(204); + } + + @Test + public void datasetTestSeda() { + RestAssured.given() + .get("/dataset/test/seda") + .then() + .statusCode(204); + } + + @Test + public void datasetTestSedaAnyOrder() { + RestAssured.given() + .get("/dataset/test/seda/any/order") + .then() + .statusCode(204); + } + + @Test + public void datasetTestSplit() { + RestAssured.given() + .get("/dataset/test/split") + .then() + .statusCode(204); + } +} diff --git a/integration-test-groups/foundation/pom.xml b/integration-test-groups/foundation/pom.xml index f813f6570d..1f00b24f91 100644 --- a/integration-test-groups/foundation/pom.xml +++ b/integration-test-groups/foundation/pom.xml @@ -43,6 +43,7 @@ <module>core-languages</module> <module>core-thread-pools</module> <module>customized-log-component</module> + <module>dataset</module> <module>direct</module> <module>eip</module> <module>language</module> diff --git a/integration-tests/foundation-grouped/pom.xml b/integration-tests/foundation-grouped/pom.xml index 2183c03927..2d5866be04 100644 --- a/integration-tests/foundation-grouped/pom.xml +++ b/integration-tests/foundation-grouped/pom.xml @@ -68,10 +68,18 @@ <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-core</artifactId> </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-dataset</artifactId> + </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-direct</artifactId> </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-file</artifactId> + </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-integration-tests-support-custom-log-component</artifactId> @@ -300,6 +308,19 @@ </exclusion> </exclusions> </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-dataset-deployment</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>*</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-direct-deployment</artifactId> @@ -313,6 +334,19 @@ </exclusion> </exclusions> </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-file-deployment</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>*</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-language-deployment</artifactId> diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml index 31e24d23c1..b8a0613b09 100644 --- a/poms/bom/pom.xml +++ b/poms/bom/pom.xml @@ -1651,6 +1651,11 @@ </exclusion> </exclusions> </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-dataset</artifactId> + <version>${camel.version}</version> + </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-datasonnet</artifactId> @@ -6669,6 +6674,16 @@ <artifactId>camel-quarkus-dataformat-deployment</artifactId> <version>${camel-quarkus.version}</version> </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-dataset</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-dataset-deployment</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-datasonnet</artifactId> diff --git a/poms/bom/src/main/generated/flattened-full-pom.xml b/poms/bom/src/main/generated/flattened-full-pom.xml index 344b323fa6..1a6eff61dc 100644 --- a/poms/bom/src/main/generated/flattened-full-pom.xml +++ b/poms/bom/src/main/generated/flattened-full-pom.xml @@ -1597,6 +1597,11 @@ </exclusion> </exclusions> </dependency> + <dependency> + <groupId>org.apache.camel</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + <artifactId>camel-dataset</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + <version>3.18.0</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + </dependency> <dependency> <groupId>org.apache.camel</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> <artifactId>camel-datasonnet</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> @@ -6613,6 +6618,16 @@ <artifactId>camel-quarkus-dataformat-deployment</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> <version>2.11.0-SNAPSHOT</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + <artifactId>camel-quarkus-dataset</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + <version>2.11.0-SNAPSHOT</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + <artifactId>camel-quarkus-dataset-deployment</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + <version>2.11.0-SNAPSHOT</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> <artifactId>camel-quarkus-datasonnet</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> diff --git a/poms/bom/src/main/generated/flattened-reduced-pom.xml b/poms/bom/src/main/generated/flattened-reduced-pom.xml index 95521da5d3..73c311ccc4 100644 --- a/poms/bom/src/main/generated/flattened-reduced-pom.xml +++ b/poms/bom/src/main/generated/flattened-reduced-pom.xml @@ -1597,6 +1597,11 @@ </exclusion> </exclusions> </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-dataset</artifactId> + <version>3.18.0</version> + </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-datasonnet</artifactId> @@ -6613,6 +6618,16 @@ <artifactId>camel-quarkus-dataformat-deployment</artifactId> <version>2.11.0-SNAPSHOT</version> </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-dataset</artifactId> + <version>2.11.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-dataset-deployment</artifactId> + <version>2.11.0-SNAPSHOT</version> + </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-datasonnet</artifactId> diff --git a/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml b/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml index c809aa7efc..404eaaa76f 100644 --- a/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml +++ b/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml @@ -1597,6 +1597,11 @@ </exclusion> </exclusions> </dependency> + <dependency> + <groupId>org.apache.camel</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + <artifactId>camel-dataset</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + <version>3.18.0</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + </dependency> <dependency> <groupId>org.apache.camel</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> <artifactId>camel-datasonnet</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> @@ -6613,6 +6618,16 @@ <artifactId>camel-quarkus-dataformat-deployment</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> <version>2.11.0-SNAPSHOT</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + <artifactId>camel-quarkus-dataset</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + <version>2.11.0-SNAPSHOT</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + <artifactId>camel-quarkus-dataset-deployment</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + <version>2.11.0-SNAPSHOT</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> + </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} --> <artifactId>camel-quarkus-datasonnet</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->