This is an automated email from the ASF dual-hosted git repository. ppalaga pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/master by this push: new 1248cd7 Feature: Add camel-mock #531 1248cd7 is described below commit 1248cd7fa8649ad739633473adc6a238dd81a004 Author: JiriOndrusek <ondrusek.j...@gmail.com> AuthorDate: Thu Jul 2 14:51:08 2020 +0200 Feature: Add camel-mock #531 --- .github/test-categories.yaml | 1 + docs/modules/ROOT/pages/extensions/mock.adoc | 28 +++++ .../pages/list-of-camel-quarkus-extensions.adoc | 4 +- extensions/mock/deployment/pom.xml | 63 ++++++++++ .../component/mock/deployment/MockProcessor.java | 30 +++++ extensions/mock/pom.xml | 39 ++++++ extensions/mock/runtime/pom.xml | 94 +++++++++++++++ .../main/resources/META-INF/quarkus-extension.yaml | 29 +++++ extensions/pom.xml | 1 + integration-tests/mock/pom.xml | 134 +++++++++++++++++++++ .../quarkus/component/mock/it/MockResource.java | 103 ++++++++++++++++ .../component/mock/it/MockRouteBuilder.java | 28 +++++ .../camel/quarkus/component/mock/it/MockIT.java | 24 ++++ .../camel/quarkus/component/mock/it/MockTest.java | 45 +++++++ integration-tests/pom.xml | 1 + poms/bom/pom.xml | 15 +++ 16 files changed, 638 insertions(+), 1 deletion(-) diff --git a/.github/test-categories.yaml b/.github/test-categories.yaml index 9bc482f..fa6396c 100644 --- a/.github/test-categories.yaml +++ b/.github/test-categories.yaml @@ -83,6 +83,7 @@ misc: - graphql - jolt - mustache + - mock - pdf - qute - stream diff --git a/docs/modules/ROOT/pages/extensions/mock.adoc b/docs/modules/ROOT/pages/extensions/mock.adoc new file mode 100644 index 0000000..fc9cc61 --- /dev/null +++ b/docs/modules/ROOT/pages/extensions/mock.adoc @@ -0,0 +1,28 @@ +// Do not edit directly! +// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page + +[[mock]] += Mock + +[.badges] +[.badge-key]##Since Camel Quarkus##[.badge-version]##1.0.0-CR3## [.badge-key]##JVM##[.badge-supported]##supported## [.badge-key]##Native##[.badge-supported]##supported## + +Test routes and mediation rules using mocks. + +== What's inside + +* https://camel.apache.org/components/latest/mock-component.html[Mock component], URI syntax: `mock:name` + +Please refer to the above link for usage and configuration details. + +== Maven coordinates + +[source,xml] +---- +<dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-mock</artifactId> +</dependency> +---- + +Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications. diff --git a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc index a4d5562..823d5f1 100644 --- a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc +++ b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc @@ -18,7 +18,7 @@ In case you are missing some Camel feature in the list: == Camel Components // components: START -Number of Camel components: 153 in 118 JAR artifacts (0 deprecated) +Number of Camel components: 154 in 119 JAR artifacts (0 deprecated) [width="100%",cols="4,1,1,1,5",options="header"] |=== @@ -230,6 +230,8 @@ Number of Camel components: 153 in 118 JAR artifacts (0 deprecated) | xref:extensions/microprofile-metrics.adoc[MicroProfile Metrics] | camel-quarkus-microprofile-metrics | Native + Stable | 0.2.0 | Expose metrics from Camel routes. +| xref:extensions/mock.adoc[Mock] | camel-quarkus-mock | Native + Stable | 1.0.0-CR3 | Test routes and mediation rules using mocks. + | xref:extensions/mongodb.adoc[MongoDB] | camel-quarkus-mongodb | Native + Stable | 1.0.0-M1 | Perform operations on MongoDB documents and collections. | xref:extensions/mongodb-gridfs.adoc[MongoDB GridFS] | camel-quarkus-mongodb-gridfs | Native + Stable | 1.0.0-M6 | Interact with MongoDB GridFS. diff --git a/extensions/mock/deployment/pom.xml b/extensions/mock/deployment/pom.xml new file mode 100644 index 0000000..edaf0b0 --- /dev/null +++ b/extensions/mock/deployment/pom.xml @@ -0,0 +1,63 @@ +<?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-mock-parent</artifactId> + <version>1.1.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-mock-deployment</artifactId> + <name>Camel Quarkus :: Mock :: 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</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/mock/deployment/src/main/java/org/apache/camel/quarkus/component/mock/deployment/MockProcessor.java b/extensions/mock/deployment/src/main/java/org/apache/camel/quarkus/component/mock/deployment/MockProcessor.java new file mode 100644 index 0000000..6af9af1 --- /dev/null +++ b/extensions/mock/deployment/src/main/java/org/apache/camel/quarkus/component/mock/deployment/MockProcessor.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.mock.deployment; + +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.FeatureBuildItem; + +class MockProcessor { + + private static final String FEATURE = "camel-mock"; + + @BuildStep + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); + } +} diff --git a/extensions/mock/pom.xml b/extensions/mock/pom.xml new file mode 100644 index 0000000..05d7018 --- /dev/null +++ b/extensions/mock/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-build-parent</artifactId> + <version>1.1.0-SNAPSHOT</version> + <relativePath>../../poms/build-parent/pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-mock-parent</artifactId> + <name>Camel Quarkus :: Mock</name> + <packaging>pom</packaging> + + <modules> + <module>deployment</module> + <module>runtime</module> + </modules> +</project> diff --git a/extensions/mock/runtime/pom.xml b/extensions/mock/runtime/pom.xml new file mode 100644 index 0000000..1ed624d --- /dev/null +++ b/extensions/mock/runtime/pom.xml @@ -0,0 +1,94 @@ +<?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-mock-parent</artifactId> + <version>1.1.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-mock</artifactId> + <name>Camel Quarkus :: Mock :: Runtime</name> + <description>Test routes and mediation rules using mocks.</description> + + <properties> + <firstVersion>1.0.0-CR3</firstVersion> + </properties> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-bom</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-core</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-mock</artifactId> + </dependency> + </dependencies> + + <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> + <plugin> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-bootstrap-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> +</project> diff --git a/extensions/mock/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/mock/runtime/src/main/resources/META-INF/quarkus-extension.yaml new file mode 100644 index 0000000..68abbd3 --- /dev/null +++ b/extensions/mock/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -0,0 +1,29 @@ +# +# 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 Mock" +description: "Test routes and mediation rules using mocks" +metadata: + guide: "https://camel.apache.org/camel-quarkus/latest/extensions/mock.html" + categories: + - "integration" diff --git a/extensions/pom.xml b/extensions/pom.xml index e5dc9d2..5757f6d 100644 --- a/extensions/pom.xml +++ b/extensions/pom.xml @@ -126,6 +126,7 @@ <module>microprofile-fault-tolerance</module> <module>microprofile-health</module> <module>microprofile-metrics</module> + <module>mock</module> <module>mongodb</module> <module>mongodb-gridfs</module> <module>mustache</module> diff --git a/integration-tests/mock/pom.xml b/integration-tests/mock/pom.xml new file mode 100644 index 0000000..0f53803 --- /dev/null +++ b/integration-tests/mock/pom.xml @@ -0,0 +1,134 @@ +<?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-integration-tests</artifactId> + <version>1.1.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-integration-test-mock</artifactId> + <name>Camel Quarkus :: Integration Tests :: Mock</name> + <description>Integration tests for Camel Quarkus Mock extension</description> + + <properties> + <!-- mvnd, a.k.a. Maven Daemon: https://github.com/gnodet/mvnd --> + <!-- The following rule tells mvnd to build the listed deployment modules before this module. --> + <!-- This is important because mvnd builds modules in parallel by default. The deployment modules are not --> + <!-- explicit dependencies of this module in the Maven sense, although they are required by the Quarkus Maven plugin. --> + <!-- Please update rule whenever you change the dependencies of this module by running --> + <!-- mvn process-resources -Pformat from the root directory --> + <mvnd.builder.rule>camel-quarkus-mock-deployment,camel-quarkus-support-policy-deployment</mvnd.builder.rule> + </properties> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-bom-test</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-mock</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-resteasy</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-log</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> + + <build> + <plugins> + <plugin> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-maven-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>build</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + + <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> + </profiles> + +</project> diff --git a/integration-tests/mock/src/main/java/org/apache/camel/quarkus/component/mock/it/MockResource.java b/integration-tests/mock/src/main/java/org/apache/camel/quarkus/component/mock/it/MockResource.java new file mode 100644 index 0000000..04f9d12 --- /dev/null +++ b/integration-tests/mock/src/main/java/org/apache/camel/quarkus/component/mock/it/MockResource.java @@ -0,0 +1,103 @@ +/* + * 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.mock.it; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.core.MediaType; + +import org.apache.camel.CamelContext; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.builder.AdviceWithRouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.model.ModelCamelContext; +import org.apache.camel.reifier.RouteReifier; +import org.jboss.logging.Logger; +import org.wildfly.common.Assert; + +@Path("/mock") +@ApplicationScoped +public class MockResource { + + private static final Logger LOG = Logger.getLogger(MockResource.class); + + @Inject + ProducerTemplate producerTemplate; + + @Inject + CamelContext context; + + @Path("/advice") + @GET + public void advice() throws Exception { + + // advice the first route using the inlined AdviceWith route builder + // which has extended capabilities than the regular route builder + RouteReifier.adviceWith(context.adapt(ModelCamelContext.class).getRouteDefinitions().get(0), context, + new AdviceWithRouteBuilder() { + @Override + public void configure() throws Exception { + // mock all endpoints + mockEndpoints(); + } + }); + + MockEndpoint mockEndpoint1 = context.getEndpoint("mock:direct:start", MockEndpoint.class); + mockEndpoint1.expectedBodiesReceived("Hello World"); + MockEndpoint mockEndpoint2 = context.getEndpoint("mock:direct:foo", MockEndpoint.class); + mockEndpoint2.expectedBodiesReceived("Hello World"); + MockEndpoint mockEndpoint3 = context.getEndpoint("mock:log:foo", MockEndpoint.class); + mockEndpoint3.expectedBodiesReceived("Bye World"); + MockEndpoint mockEndpoint4 = context.getEndpoint("mock:result", MockEndpoint.class); + mockEndpoint4.expectedBodiesReceived("Bye World"); + + producerTemplate.sendBody("direct:start", "Hello World"); + + mockEndpoint1.assertIsSatisfied(); + mockEndpoint2.assertIsSatisfied(); + mockEndpoint3.assertIsSatisfied(); + mockEndpoint4.assertIsSatisfied(); + + // test to ensure correct endpoints in registry + Assert.assertNotNull(context.hasEndpoint("direct:start")); + Assert.assertNotNull(context.hasEndpoint("direct:foo")); + Assert.assertNotNull(context.hasEndpoint("log:foo")); + Assert.assertNotNull(context.hasEndpoint("mock:result")); + // all the endpoints was mocked + Assert.assertNotNull(context.hasEndpoint("mock:direct:start")); + Assert.assertNotNull(context.hasEndpoint("mock:direct:foo")); + Assert.assertNotNull(context.hasEndpoint("mock:log:foo")); + } + + @Path("/basic") + @POST + @Consumes(MediaType.TEXT_PLAIN) + public void post(String message) throws Exception { + MockEndpoint mockEndpoint = context.getEndpoint("mock:foo", MockEndpoint.class); + mockEndpoint.expectedBodyReceived().constant(message); + mockEndpoint.setExpectedCount(1); + LOG.infof("Sending to mock: %s", message); + final String response = producerTemplate.requestBody("mock:foo", message, String.class); + LOG.infof("Got response from mock: %s", response); + + mockEndpoint.assertIsSatisfied(); + } +} diff --git a/integration-tests/mock/src/main/java/org/apache/camel/quarkus/component/mock/it/MockRouteBuilder.java b/integration-tests/mock/src/main/java/org/apache/camel/quarkus/component/mock/it/MockRouteBuilder.java new file mode 100644 index 0000000..acee562 --- /dev/null +++ b/integration-tests/mock/src/main/java/org/apache/camel/quarkus/component/mock/it/MockRouteBuilder.java @@ -0,0 +1,28 @@ +/* + * 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.mock.it; + +import org.apache.camel.builder.RouteBuilder; + +public class MockRouteBuilder extends RouteBuilder { + @Override + public void configure() { + from("direct:start").to("direct:foo").to("log:foo").to("mock:result"); + + from("direct:foo").transform(constant("Bye World")); + } +} diff --git a/integration-tests/mock/src/test/java/org/apache/camel/quarkus/component/mock/it/MockIT.java b/integration-tests/mock/src/test/java/org/apache/camel/quarkus/component/mock/it/MockIT.java new file mode 100644 index 0000000..6b76d0d --- /dev/null +++ b/integration-tests/mock/src/test/java/org/apache/camel/quarkus/component/mock/it/MockIT.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.mock.it; + +import io.quarkus.test.junit.NativeImageTest; + +@NativeImageTest +class MockIT extends MockTest { + +} diff --git a/integration-tests/mock/src/test/java/org/apache/camel/quarkus/component/mock/it/MockTest.java b/integration-tests/mock/src/test/java/org/apache/camel/quarkus/component/mock/it/MockTest.java new file mode 100644 index 0000000..2c5b733 --- /dev/null +++ b/integration-tests/mock/src/test/java/org/apache/camel/quarkus/component/mock/it/MockTest.java @@ -0,0 +1,45 @@ +/* + * 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.mock.it; + +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; +import io.restassured.http.ContentType; +import org.junit.jupiter.api.Test; + +@QuarkusTest +class MockTest { + + @Test + public void basic() { + final String msg = java.util.UUID.randomUUID().toString().replace("-", ""); + RestAssured.given() // + .contentType(ContentType.TEXT) + .body(msg) + .post("/mock/basic") // + .then() + .statusCode(204); + } + + @Test + public void advice() { + RestAssured.get("/mock/advice") + .then() + .statusCode(204); + } + +} diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index 3429627..7bf7399 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -109,6 +109,7 @@ <module>mail</module> <module>messaging</module> <module>microprofile</module> + <module>mock</module> <module>mongodb</module> <module>mustache</module> <module>netty</module> diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml index 4c3ebdf..13332de 100644 --- a/poms/bom/pom.xml +++ b/poms/bom/pom.xml @@ -867,6 +867,11 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> + <artifactId>camel-mock</artifactId> + <version>${camel.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> <artifactId>camel-mongodb</artifactId> <version>${camel.version}</version> <exclusions> @@ -2265,6 +2270,16 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-mock</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-mock-deployment</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-mongodb</artifactId> <version>${camel-quarkus.version}</version> </dependency>