From beac8e439423121a227e72b23b6d689a577cc4e1 Mon Sep 17 00:00:00 2001 From: JiriOndrusek Date: Mon, 13 Jun 2022 11:36:06 +0200 Subject: [PATCH] CamelTestSupport style of testing #3511 --- extensions-core/core/deployment/pom.xml | 8 + .../core/deployment/CamelTestProcessor.java | 101 ++++++++++ .../deployment/InjectionPointsProcessor.java | 24 ++- integration-tests-jvm/stub/pom.xml | 7 + integration-tests-support/pom.xml | 1 + .../test-support-jvm/pom.xml | 62 ++++++ .../quarkus/test/BeforeEachCallback.java | 31 +++ .../camel/quarkus/test/CamelQuarkusTest.java | 14 ++ .../quarkus/test/CamelQuarkusTestSupport.java | 47 +++++ ...nit.callback.QuarkusTestBeforeEachCallback | 1 + .../quarkus/test/AdviceWithLambdaTest.java | 58 ++++++ .../test/AdviceWithNotStartedTest.java | 80 ++++++++ .../CreateCamelContextPerTestFalseTest.java | 120 ++++++++++++ .../CreateCamelContextPerTestTrueTest.java | 158 +++++++++++++++ .../quarkus/test/DebugJUnit5Test.java | 93 +++++++++ .../test/DebugNoLazyTypeConverterTest.java | 91 +++++++++ .../apachencamel/quarkus/test/DebugTest.java | 91 +++++++++ .../FilterCreateCamelContextPerClassTest.java | 61 ++++++ .../test/FilterFluentTemplateTest.java | 77 ++++++++ .../quarkus/test/FilterJUnit5Test.java | 71 +++++++ .../apachencamel/quarkus/test/FilterTest.java | 77 ++++++++ .../quarkus/test/GetMockEndpointTest.java | 47 +++++ .../IsMockEndpointsAndSkipJUnit5Test.java | 70 +++++++ .../quarkus/test/IsMockEndpointsFileTest.java | 73 +++++++ .../test/IsMockEndpointsJUnit5Test.java | 76 ++++++++ .../quarkus/test/IsMockEndpointsTest.java | 67 +++++++ .../test/MockEndpointFailNoHeaderTest.java | 65 +++++++ .../quarkus/test/MyProduceBean.java | 32 ++++ .../apachencamel/quarkus/test/MySender.java | 25 +++ .../quarkus/test/ProduceBeanTest.java | 45 +++++ .../RouteBuilderConfigureExceptionTest.java | 56 ++++++ .../RouteProcessorDumpRouteCoverageTest.java | 75 ++++++++ .../quarkus/test/SimpleMockEndpointsTest.java | 57 ++++++ .../quarkus/test/SimpleMockTest.java | 53 ++++++ .../quarkus/test/SimpleNotifyBuilderTest.java | 55 ++++++ .../test/SimpleWeaveAddMockLastTest.java | 63 ++++++ ...PropertiesWithPropertiesComponentTest.java | 79 ++++++++ poms/bom-test/pom.xml | 2 + poms/bom/pom.xml | 180 ++++++++++-------- 39 files changed, 2306 insertions(+), 87 deletions(-) create mode 100644 extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelTestProcessor.java create mode 100644 integration-tests-support/test-support-jvm/pom.xml create mode 100644 integration-tests-support/test-support-jvm/src/main/java/org/apache/camel/quarkus/test/BeforeEachCallback.java create mode 100644 integration-tests-support/test-support-jvm/src/main/java/org/apache/camel/quarkus/test/CamelQuarkusTest.java create mode 100644 integration-tests-support/test-support-jvm/src/main/java/org/apache/camel/quarkus/test/CamelQuarkusTestSupport.java create mode 100644 integration-tests-support/test-support-jvm/src/main/resources/META-INF/services/io.quarkus.test.junit.callback.QuarkusTestBeforeEachCallback create mode 100644 integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/AdviceWithLambdaTest.java create mode 100644 integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/AdviceWithNotStartedTest.java create mode 100644 integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/CreateCamelContextPerTestFalseTest.java create mode 100644 integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/CreateCamelContextPerTestTrueTest.java create mode 100644 integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/DebugJUnit5Test.java create mode 100644 integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/DebugNoLazyTypeConverterTest.java create mode 100644 integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/DebugTest.java create mode 100644 integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/FilterCreateCamelContextPerClassTest.java create mode 100644 integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/FilterFluentTemplateTest.java create mode 100644 integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/FilterJUnit5Test.java create mode 100644 integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/FilterTest.java create mode 100644 integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/GetMockEndpointTest.java create mode 100644 integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/IsMockEndpointsAndSkipJUnit5Test.java create mode 100644 integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/IsMockEndpointsFileTest.java create mode 100644 integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/IsMockEndpointsJUnit5Test.java create mode 100644 integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/IsMockEndpointsTest.java create mode 100644 integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/MockEndpointFailNoHeaderTest.java create mode 100644 integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/MyProduceBean.java create mode 100644 integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/MySender.java create mode 100644 integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/ProduceBeanTest.java create mode 100644 integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/RouteBuilderConfigureExceptionTest.java create mode 100644 integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/RouteProcessorDumpRouteCoverageTest.java create mode 100644 integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/SimpleMockEndpointsTest.java create mode 100644 integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/SimpleMockTest.java create mode 100644 integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/SimpleNotifyBuilderTest.java create mode 100644 integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/SimpleWeaveAddMockLastTest.java create mode 100644 integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/UseOverridePropertiesWithPropertiesComponentTest.java diff --git a/extensions-core/core/deployment/pom.xml b/extensions-core/core/deployment/pom.xml index a26dd6c5d033..7371f54600b3 100644 --- a/extensions-core/core/deployment/pom.xml +++ b/extensions-core/core/deployment/pom.xml @@ -37,6 +37,10 @@ io.quarkus quarkus-arc-deployment + + io.quarkus.arc + arc-processor + @@ -59,6 +63,10 @@ org.jboss.spec.javax.xml.bind jboss-jaxb-api_2.3_spec + + org.apache.camel.quarkus + camel-quarkus-integration-test-support-jvm + diff --git a/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelTestProcessor.java b/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelTestProcessor.java new file mode 100644 index 000000000000..bec7729cd06b --- /dev/null +++ b/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelTestProcessor.java @@ -0,0 +1,101 @@ +/* + * 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.core.deployment; + +import javax.inject.Inject; + +import io.quarkus.arc.deployment.AnnotationsTransformerBuildItem; +import io.quarkus.arc.processor.AnnotationsTransformer; +import io.quarkus.deployment.annotations.BuildProducer; +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.TestAnnotationBuildItem; +import io.quarkus.test.junit.TestProfile; +import org.apache.camel.Produce; +import org.apache.camel.quarkus.test.CamelQuarkusTest; +import org.jboss.jandex.AnnotationInstance; +import org.jboss.jandex.AnnotationTarget; +import org.jboss.jandex.AnnotationValue; +import org.jboss.jandex.DotName; +import org.jboss.jandex.Type; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class CamelTestProcessor { + private static final Logger LOGGER = LoggerFactory.getLogger(CamelTestProcessor.class); + + @BuildStep + void produceTestAnnotationBuildItem(BuildProducer testAnnotationBuildItems) { + testAnnotationBuildItems.produce(new TestAnnotationBuildItem(CamelQuarkusTest.class.getName())); + } + + @BuildStep + void annotationTransformerBuildItem(BuildProducer annotationsTransformerBuildItems) { + annotationsTransformerBuildItems.produce(removeProduces(null)); + annotationsTransformerBuildItems.produce(createAnnotationTransformer(null)); + } + + private AnnotationsTransformerBuildItem createAnnotationTransformer(DotName className) { + return new AnnotationsTransformerBuildItem(new AnnotationsTransformer() { + public boolean appliesTo(org.jboss.jandex.AnnotationTarget.Kind kind) { + return kind == AnnotationTarget.Kind.CLASS; + } + + public void transform(TransformationContext context) { + + if (context.getAnnotations().contains( + AnnotationInstance.create( + DotName.createSimple(CamelQuarkusTest.class.getName()), + context.getTarget(), + new AnnotationValue[] {}))) { + context.transform().add(AnnotationInstance.create( + DotName.createSimple(TestProfile.class.getName()), + context.getTarget(), + new AnnotationValue[] { AnnotationValue.createClassValue("value", + Type.create(context.getTarget().asClass().name(), Type.Kind.CLASS)) })) + .done(); + } + } + }); + } + + private AnnotationsTransformerBuildItem removeProduces(DotName className) { + return new AnnotationsTransformerBuildItem(new AnnotationsTransformer() { + public boolean appliesTo(org.jboss.jandex.AnnotationTarget.Kind kind) { + return kind == AnnotationTarget.Kind.FIELD; + } + + public void transform(TransformationContext context) { + if (context.getTarget().asField().name().equals("template1")) { + AnnotationInstance ai = AnnotationInstance.create( + DotName.createSimple(Produce.class.getName()), + null, + new AnnotationValue[] { AnnotationValue.createStringValue("value", "direct:start") }); + context.transform().remove(p -> p.name().toString().contains(Produce.class.getName())).done(); + context.transform().add(AnnotationInstance.create(DotName.createSimple(Inject.class.getName()), //todo valiue direxct:start + context.getTarget(), new AnnotationValue[] {})).done(); + } + } + }); + } + + // @BuildStep + // void doSomethingWithNamedBeans(SynthesisFinishedBuildItem synthesisFinished) { + // List namedBeans = synthesisFinished.beanStream().withName().collect(Collectors.toList()); + // System.out.println(namedBeans); + // } + +} diff --git a/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/InjectionPointsProcessor.java b/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/InjectionPointsProcessor.java index e8ced1788acf..52a95f960a24 100644 --- a/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/InjectionPointsProcessor.java +++ b/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/InjectionPointsProcessor.java @@ -56,6 +56,7 @@ import org.apache.camel.quarkus.core.CamelRecorder; import org.apache.camel.quarkus.core.InjectionPointsRecorder; import org.apache.camel.quarkus.core.deployment.spi.CamelRuntimeTaskBuildItem; +import org.apache.camel.quarkus.test.CamelQuarkusTest; import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.AnnotationTarget; import org.jboss.jandex.AnnotationTarget.Kind; @@ -226,12 +227,16 @@ void syntheticBeans( BuildProducer syntheticBeans, BuildProducer proxyDefinitions) { + Set alreadyCreated = new HashSet<>(); + for (AnnotationInstance annot : index.getIndex().getAnnotations(ENDPOINT_INJECT_ANNOTATION)) { final AnnotationTarget target = annot.target(); switch (target.kind()) { case FIELD: { final FieldInfo field = target.asField(); - endpointInjectBeans(recorder, syntheticBeans, index.getIndex(), annot, field.type().name()); + if (!excludeTestSyntheticBeanDuplicities(annot, alreadyCreated, field.declaringClass())) { + endpointInjectBeans(recorder, syntheticBeans, index.getIndex(), annot, field.type().name()); + } break; } case METHOD: { @@ -251,8 +256,10 @@ void syntheticBeans( switch (target.kind()) { case FIELD: { final FieldInfo field = target.asField(); - produceBeans(recorder, capabilities, syntheticBeans, proxyDefinitions, beanCapabilityAvailable, - index.getIndex(), annot, field.type().name(), field.name(), field.declaringClass().name()); + if (!excludeTestSyntheticBeanDuplicities(annot, alreadyCreated, field.declaringClass())) { + produceBeans(recorder, capabilities, syntheticBeans, proxyDefinitions, beanCapabilityAvailable, + index.getIndex(), annot, field.type().name(), field.name(), field.declaringClass().name()); + } break; } case METHOD: { @@ -266,6 +273,17 @@ void syntheticBeans( } } + private boolean excludeTestSyntheticBeanDuplicities(AnnotationInstance annot, Set alreadyCreated, + ClassInfo declaringClass) { + if (declaringClass.annotations().containsKey(DotName.createSimple(CamelQuarkusTest.class.getName()))) { + if (!alreadyCreated.contains(annot.toString())) { + alreadyCreated.add(annot.toString()); + return false; + } + } + return true; + } + void produceBeans(CamelRecorder recorder, List capabilities, BuildProducer syntheticBeans, BuildProducer proxyDefinitions, diff --git a/integration-tests-jvm/stub/pom.xml b/integration-tests-jvm/stub/pom.xml index 3bfb14b0fe07..c2537a8a5c66 100644 --- a/integration-tests-jvm/stub/pom.xml +++ b/integration-tests-jvm/stub/pom.xml @@ -51,6 +51,13 @@ rest-assured test + + + org.apache.camel.quarkus + camel-quarkus-integration-test-support-jvm + + test + diff --git a/integration-tests-support/pom.xml b/integration-tests-support/pom.xml index dd8af21537ac..58783656e7b5 100644 --- a/integration-tests-support/pom.xml +++ b/integration-tests-support/pom.xml @@ -48,6 +48,7 @@ mongodb process-executor-support test-support + test-support-jvm mock-backend wiremock xslt-support diff --git a/integration-tests-support/test-support-jvm/pom.xml b/integration-tests-support/test-support-jvm/pom.xml new file mode 100644 index 000000000000..81b84e8bf11d --- /dev/null +++ b/integration-tests-support/test-support-jvm/pom.xml @@ -0,0 +1,62 @@ + + + + + org.apache.camel.quarkus + camel-quarkus-integration-tests-support + 2.10.0-SNAPSHOT + ../pom.xml + + 4.0.0 + + camel-quarkus-integration-test-support-jvm + Camel Quarkus :: Integration Tests :: Support + + + + org.slf4j + slf4j-api + + + io.quarkus + quarkus-junit5 + + + org.assertj + assertj-core + + + org.junit.jupiter + junit-jupiter-engine + + + org.apache.camel.quarkus + camel-quarkus-integration-test-support + + + org.apache.camel.quarkus + camel-quarkus-core + + + org.apache.camel + camel-test-junit5 + + + diff --git a/integration-tests-support/test-support-jvm/src/main/java/org/apache/camel/quarkus/test/BeforeEachCallback.java b/integration-tests-support/test-support-jvm/src/main/java/org/apache/camel/quarkus/test/BeforeEachCallback.java new file mode 100644 index 000000000000..b44ed3d962a2 --- /dev/null +++ b/integration-tests-support/test-support-jvm/src/main/java/org/apache/camel/quarkus/test/BeforeEachCallback.java @@ -0,0 +1,31 @@ +package org.apache.camel.quarkus.test; + +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.stream.Collectors; + +import io.quarkus.test.junit.callback.QuarkusTestBeforeEachCallback; +import io.quarkus.test.junit.callback.QuarkusTestMethodContext; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.engine.execution.ExtensionValuesStore; +import org.junit.jupiter.engine.execution.NamespaceAwareStore; + +public class BeforeEachCallback implements QuarkusTestBeforeEachCallback { + + @Override + public void beforeEach(QuarkusTestMethodContext context) { + CamelQuarkusTestSupport testInstance = (CamelQuarkusTestSupport) context.getTestInstance(); + + testInstance.setCurrentTestName(getDisplayName(context.getTestMethod())); + testInstance.setGlobalStore(new NamespaceAwareStore(new ExtensionValuesStore(null), ExtensionContext.Namespace.GLOBAL)); + } + + private String getDisplayName(Method method) { + StringBuilder sb = new StringBuilder(method.getName()); + sb.append("("); + sb.append(Arrays.stream(method.getParameterTypes()).map(c -> c.getSimpleName()).collect(Collectors.joining(", "))); + sb.append(")"); + + return sb.toString(); + } +} diff --git a/integration-tests-support/test-support-jvm/src/main/java/org/apache/camel/quarkus/test/CamelQuarkusTest.java b/integration-tests-support/test-support-jvm/src/main/java/org/apache/camel/quarkus/test/CamelQuarkusTest.java new file mode 100644 index 000000000000..5f287b03d748 --- /dev/null +++ b/integration-tests-support/test-support-jvm/src/main/java/org/apache/camel/quarkus/test/CamelQuarkusTest.java @@ -0,0 +1,14 @@ +package org.apache.camel.quarkus.test; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import io.quarkus.test.junit.QuarkusTest; + +@Target({ ElementType.TYPE, ElementType.METHOD }) +@Retention(RetentionPolicy.RUNTIME) +@QuarkusTest +public @interface CamelQuarkusTest { +} diff --git a/integration-tests-support/test-support-jvm/src/main/java/org/apache/camel/quarkus/test/CamelQuarkusTestSupport.java b/integration-tests-support/test-support-jvm/src/main/java/org/apache/camel/quarkus/test/CamelQuarkusTestSupport.java new file mode 100644 index 000000000000..8b2238ebc86e --- /dev/null +++ b/integration-tests-support/test-support-jvm/src/main/java/org/apache/camel/quarkus/test/CamelQuarkusTestSupport.java @@ -0,0 +1,47 @@ +package org.apache.camel.quarkus.test; + +import io.quarkus.test.junit.QuarkusTestProfile; +import org.apache.camel.test.junit5.CamelTestSupport; +import org.junit.jupiter.api.extension.ExtensionContext; + +public class CamelQuarkusTestSupport extends CamelTestSupport + implements QuarkusTestProfile { + + @Override + public void beforeAll(ExtensionContext context) { + //in camel-quarkus, junit5 uses different classloader, necessaryu code was moved into quarkus's callback + } + + @Override + public void beforeEach(ExtensionContext context) throws Exception { + //in camel-quarkus, junit5 uses different classloader, necessaryu code was moved into quarkus's callback + } + + @Override + public void beforeTestExecution(ExtensionContext context) throws Exception { + //in camel-quarkus, junit5 uses different classloader, necessaryu code was moved into quarkus's callback + } + + @Override + public void afterAll(ExtensionContext context) { + //in camel-quarkus, junit5 uses different classloader, necessaryu code was moved into quarkus's callback + } + + @Override + public void afterEach(ExtensionContext context) throws Exception { + //in camel-quarkus, junit5 uses different classloader, necessaryu code was moved into quarkus's callback + } + + @Override + public void afterTestExecution(ExtensionContext context) throws Exception { + //in camel-quarkus, junit5 uses different classloader, necessaryu code was moved into quarkus's callback + } + + void setCurrentTestName(String currentTestName) { + this.currentTestName = currentTestName; + } + + void setGlobalStore(ExtensionContext.Store store) { + this.globalStore = store; + } +} diff --git a/integration-tests-support/test-support-jvm/src/main/resources/META-INF/services/io.quarkus.test.junit.callback.QuarkusTestBeforeEachCallback b/integration-tests-support/test-support-jvm/src/main/resources/META-INF/services/io.quarkus.test.junit.callback.QuarkusTestBeforeEachCallback new file mode 100644 index 000000000000..0887c9994488 --- /dev/null +++ b/integration-tests-support/test-support-jvm/src/main/resources/META-INF/services/io.quarkus.test.junit.callback.QuarkusTestBeforeEachCallback @@ -0,0 +1 @@ +org.apache.camel.quarkus.test.BeforeEachCallback diff --git a/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/AdviceWithLambdaTest.java b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/AdviceWithLambdaTest.java new file mode 100644 index 000000000000..b65613e0c4b5 --- /dev/null +++ b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/AdviceWithLambdaTest.java @@ -0,0 +1,58 @@ +/* + * 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.apachencamel.quarkus.test; + +import org.apache.camel.RoutesBuilder; +import org.apache.camel.builder.AdviceWith; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.quarkus.test.CamelQuarkusTest; +import org.apache.camel.quarkus.test.CamelQuarkusTestSupport; +import org.junit.jupiter.api.Test; + +@CamelQuarkusTest +public class AdviceWithLambdaTest extends CamelQuarkusTestSupport { + + @Override + public boolean isUseAdviceWith() { + return true; + } + + @Test + public void testAdviceWith() throws Exception { + getMockEndpoint("mock:result").expectedMessageCount(1); + + // advice the route in one line + AdviceWith.adviceWith(context, "foo", a -> a.weaveAddLast().to("mock:result")); + + // start Camel + context.start(); + + template.sendBody("direct:start", "Bye World"); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RoutesBuilder createRouteBuilder() { + return new RouteBuilder() { + @Override + public void configure() { + from("direct:start").routeId("foo").to("log:foo"); + } + }; + } +} diff --git a/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/AdviceWithNotStartedTest.java b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/AdviceWithNotStartedTest.java new file mode 100644 index 000000000000..069740de52e0 --- /dev/null +++ b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/AdviceWithNotStartedTest.java @@ -0,0 +1,80 @@ +/* + * 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.apachencamel.quarkus.test; + +import java.util.concurrent.RejectedExecutionException; + +import org.apache.camel.CamelExecutionException; +import org.apache.camel.RoutesBuilder; +import org.apache.camel.builder.AdviceWith; +import org.apache.camel.builder.AdviceWithRouteBuilder; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.model.Model; +import org.apache.camel.quarkus.test.CamelQuarkusTest; +import org.apache.camel.quarkus.test.CamelQuarkusTestSupport; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf; +import static org.junit.jupiter.api.Assertions.fail; + +@CamelQuarkusTest +public class AdviceWithNotStartedTest extends CamelQuarkusTestSupport { + + @Override + public boolean isUseAdviceWith() { + return true; + } + + @Test + @Disabled //camel quarkus runs test with started context + public void testNotStarted() throws Exception { + AdviceWith.adviceWith(context.getExtension(Model.class).getRouteDefinition("foo"), context, + new AdviceWithRouteBuilder() { + @Override + public void configure() { + weaveAddLast().to("mock:result"); + } + }); + + getMockEndpoint("mock:result").expectedMessageCount(1); + + try { + template.sendBody("direct:start", "Hello World"); + fail("Should throw exception"); + } catch (CamelExecutionException e) { + assertIsInstanceOf(RejectedExecutionException.class, e.getCause()); + } + + // start Camel + context.start(); + + template.sendBody("direct:start", "Bye World"); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RoutesBuilder createRouteBuilder() { + return new RouteBuilder() { + @Override + public void configure() { + from("direct:start").routeId("foo").to("log:foo"); + } + }; + } +} diff --git a/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/CreateCamelContextPerTestFalseTest.java b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/CreateCamelContextPerTestFalseTest.java new file mode 100644 index 000000000000..89447d03209b --- /dev/null +++ b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/CreateCamelContextPerTestFalseTest.java @@ -0,0 +1,120 @@ +/* + * 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.apachencamel.quarkus.test; + +import java.util.concurrent.atomic.AtomicInteger; + +import org.apache.camel.CamelContext; +import org.apache.camel.EndpointInject; +import org.apache.camel.Produce; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.quarkus.test.CamelQuarkusTest; +import org.apache.camel.quarkus.test.CamelQuarkusTestSupport; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +@CamelQuarkusTest +@TestInstance(TestInstance.Lifecycle.PER_METHOD) +@Disabled //differences between camel-quarkus and camel +public class CreateCamelContextPerTestFalseTest extends CamelQuarkusTestSupport { + + private static final Logger LOG = LoggerFactory.getLogger(CreateCamelContextPerTestFalseTest.class); + + private static final AtomicInteger CREATED_CONTEXTS = new AtomicInteger(); + private static final AtomicInteger POST_TEAR_DOWN = new AtomicInteger(); + + @EndpointInject("mock:result") + protected MockEndpoint resultEndpoint; + + @Produce("direct:start") + protected ProducerTemplate template; + + @Override + protected CamelContext createCamelContext() throws Exception { + LOG.info("createCamelContext()"); + CREATED_CONTEXTS.incrementAndGet(); + return super.createCamelContext(); + } + + @Override + protected void doPostTearDown() throws Exception { + LOG.info("doPostTearDown()"); + POST_TEAR_DOWN.incrementAndGet(); + super.doPostTearDown(); + } + + @Test + public void testSendMatchingMessage() throws Exception { + String expectedBody = ""; + + resultEndpoint.expectedBodiesReceived(expectedBody); + + template.sendBodyAndHeader(expectedBody, "foo", "bar"); + + resultEndpoint.assertIsSatisfied(); + + assertTrue(CREATED_CONTEXTS.get() >= 1, "Should create 1 or more CamelContext per test class"); + } + + @Test + public void testSendAnotherMatchingMessage() throws Exception { + String expectedBody = ""; + + resultEndpoint.expectedBodiesReceived(expectedBody); + + template.sendBodyAndHeader(expectedBody, "foo", "bar"); + + resultEndpoint.assertIsSatisfied(); + + assertTrue(CREATED_CONTEXTS.get() >= 1, "Should create 1 or more CamelContext per test class"); + } + + @Test + public void testSendNotMatchingMessage() throws Exception { + resultEndpoint.expectedMessageCount(0); + + template.sendBodyAndHeader("", "foo", "notMatchedHeaderValue"); + + resultEndpoint.assertIsSatisfied(); + + assertTrue(CREATED_CONTEXTS.get() >= 1, "Should create 1 or more CamelContext per test class"); + } + + @AfterAll + public static void validateTearDown() { + assertEquals(3, CREATED_CONTEXTS.get()); + assertEquals(3, POST_TEAR_DOWN.get()); + } + + @Override + protected RouteBuilder createRouteBuilder() { + return new RouteBuilder() { + public void configure() { + from("direct:start").filter(header("foo").isEqualTo("bar")).to("mock:result"); + } + }; + } +} diff --git a/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/CreateCamelContextPerTestTrueTest.java b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/CreateCamelContextPerTestTrueTest.java new file mode 100644 index 000000000000..41a29d58a7b9 --- /dev/null +++ b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/CreateCamelContextPerTestTrueTest.java @@ -0,0 +1,158 @@ +/* + * 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.apachencamel.quarkus.test; + +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +import org.apache.camel.CamelContext; +import org.apache.camel.EndpointInject; +import org.apache.camel.Produce; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.quarkus.test.CamelQuarkusTest; +import org.apache.camel.quarkus.test.CamelQuarkusTestSupport; +import org.apache.camel.util.StopWatch; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +@CamelQuarkusTest +@TestInstance(TestInstance.Lifecycle.PER_CLASS) +@Disabled //differences between camel-quarkus and camel +public class CreateCamelContextPerTestTrueTest extends CamelQuarkusTestSupport { + + private static final Logger LOG = LoggerFactory.getLogger(CreateCamelContextPerTestTrueTest.class); + + private static final AtomicInteger CREATED_CONTEXTS = new AtomicInteger(); + private static final AtomicInteger POST_TEAR_DOWN = new AtomicInteger(); + private static final CountDownLatch LATCH = new CountDownLatch(1); + + @EndpointInject("mock:result") + protected MockEndpoint resultEndpoint; + + @Produce("direct:start") + protected ProducerTemplate template; + + @Override + protected CamelContext createCamelContext() throws Exception { + LOG.info("createCamelContext()"); + CREATED_CONTEXTS.incrementAndGet(); + return super.createCamelContext(); + } + + @Override + protected void doPostTearDown() throws Exception { + LOG.info("doPostTearDown()"); + POST_TEAR_DOWN.incrementAndGet(); + super.doPostTearDown(); + LATCH.await(5, TimeUnit.SECONDS); + } + + @Test + public void testSendMatchingMessage() throws Exception { + String expectedBody = ""; + + resultEndpoint.expectedBodiesReceived(expectedBody); + + template.sendBodyAndHeader(expectedBody, "foo", "bar"); + + resultEndpoint.assertIsSatisfied(); + + assertEquals(1, CREATED_CONTEXTS.get(), "Should only create 1 CamelContext per test class"); + assertEquals(0, POST_TEAR_DOWN.get(), "Should not call postTearDown yet"); + + resultEndpoint.reset(); + } + + @Test + public void testSendAnotherMatchingMessage() throws Exception { + String expectedBody = ""; + + resultEndpoint.expectedBodiesReceived(expectedBody); + + template.sendBodyAndHeader(expectedBody, "foo", "bar"); + + resultEndpoint.assertIsSatisfied(); + + assertEquals(1, CREATED_CONTEXTS.get(), "Should only create 1 CamelContext per test class"); + assertEquals(0, POST_TEAR_DOWN.get(), "Should not call postTearDown yet"); + + resultEndpoint.reset(); + } + + @Test + public void testSendNotMatchingMessage() throws Exception { + resultEndpoint.expectedMessageCount(0); + + template.sendBodyAndHeader("", "foo", "notMatchedHeaderValue"); + + resultEndpoint.assertIsSatisfied(); + + assertEquals(1, CREATED_CONTEXTS.get(), "Should only create 1 CamelContext per test class"); + assertEquals(0, POST_TEAR_DOWN.get(), "Should not call postTearDown yet"); + + resultEndpoint.reset(); + } + + @AfterAll + public static void shouldTearDown() { + // we are called before doPostTearDown so lets wait for that to be + // called + Runnable r = () -> { + try { + StopWatch watch = new StopWatch(); + while (watch.taken() < 5000) { + LOG.debug("Checking for tear down called correctly"); + if (POST_TEAR_DOWN.get() == 1) { + LATCH.countDown(); + break; + } else { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + break; + } + } + } + } finally { + LOG.info("Should only call postTearDown 1 time per test class, called: " + POST_TEAR_DOWN.get()); + assertEquals(1, POST_TEAR_DOWN.get(), "Should only call postTearDown 1 time per test class"); + } + }; + Thread t = new Thread(r); + t.setDaemon(false); + t.setName("shouldTearDown checker"); + t.start(); + } + + @Override + protected RouteBuilder createRouteBuilder() { + return new RouteBuilder() { + public void configure() { + from("direct:start").filter(header("foo").isEqualTo("bar")).to("mock:result"); + } + }; + } +} diff --git a/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/DebugJUnit5Test.java b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/DebugJUnit5Test.java new file mode 100644 index 000000000000..186c37e2b6dc --- /dev/null +++ b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/DebugJUnit5Test.java @@ -0,0 +1,93 @@ +/* + * 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.apachencamel.quarkus.test; + +import org.apache.camel.Exchange; +import org.apache.camel.Processor; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.model.ProcessorDefinition; +import org.apache.camel.quarkus.test.CamelQuarkusTest; +import org.apache.camel.quarkus.test.CamelQuarkusTestSupport; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@CamelQuarkusTest +@TestInstance(TestInstance.Lifecycle.PER_CLASS) +public class DebugJUnit5Test extends CamelQuarkusTestSupport { + + private static final Logger LOG = LoggerFactory.getLogger(DebugJUnit5Test.class); + + // START SNIPPET: e1 + @Override + public boolean isUseDebugger() { + // must enable debugger + return true; + } + + @Override + protected void debugBefore( + Exchange exchange, Processor processor, ProcessorDefinition definition, String id, String shortName) { + // this method is invoked before we are about to enter the given + // processor + // from your Java editor you can just add a breakpoint in the code line + // below + LOG.info("Before " + definition + " with body " + exchange.getIn().getBody()); + } + // END SNIPPET: e1 + + @Test + public void testDebugger() throws Exception { + // set mock expectations + getMockEndpoint("mock:a").expectedMessageCount(1); + getMockEndpoint("mock:b").expectedMessageCount(1); + + // send a message + template.sendBody("direct:start", "World"); + + // assert mocks + assertMockEndpointsSatisfied(); + } + + @Test + public void testTwo() throws Exception { + // set mock expectations + getMockEndpoint("mock:a").expectedMessageCount(2); + getMockEndpoint("mock:b").expectedMessageCount(2); + + // send a message + template.sendBody("direct:start", "World"); + template.sendBody("direct:start", "Camel"); + + // assert mocks + assertMockEndpointsSatisfied(); + } + + // START SNIPPET: e2 + @Override + protected RouteBuilder createRouteBuilder() { + return new RouteBuilder() { + @Override + public void configure() { + // this is the route we want to debug + from("direct:start").to("mock:a").transform(body().prepend("Hello ")).to("mock:b"); + } + }; + } + // END SNIPPET: e2 +} diff --git a/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/DebugNoLazyTypeConverterTest.java b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/DebugNoLazyTypeConverterTest.java new file mode 100644 index 000000000000..77530b5ea827 --- /dev/null +++ b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/DebugNoLazyTypeConverterTest.java @@ -0,0 +1,91 @@ +/* + * 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.apachencamel.quarkus.test; + +import org.apache.camel.Exchange; +import org.apache.camel.Processor; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.model.ProcessorDefinition; +import org.apache.camel.quarkus.test.CamelQuarkusTest; +import org.apache.camel.quarkus.test.CamelQuarkusTestSupport; +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@CamelQuarkusTest +public class DebugNoLazyTypeConverterTest extends CamelQuarkusTestSupport { + + private static final Logger LOG = LoggerFactory.getLogger(DebugNoLazyTypeConverterTest.class); + + // START SNIPPET: e1 + @Override + public boolean isUseDebugger() { + // must enable debugger + return true; + } + + @Override + protected void debugBefore( + Exchange exchange, Processor processor, ProcessorDefinition definition, String id, String shortName) { + // this method is invoked before we are about to enter the given + // processor + // from your Java editor you can just add a breakpoint in the code line + // below + LOG.info("Before " + definition + " with body " + exchange.getIn().getBody()); + } + // END SNIPPET: e1 + + @Test + public void testDebugger() throws Exception { + // set mock expectations + getMockEndpoint("mock:a").expectedMessageCount(1); + getMockEndpoint("mock:b").expectedMessageCount(1); + + // send a message + template.sendBody("direct:start", "World"); + + // assert mocks + assertMockEndpointsSatisfied(); + } + + @Test + public void testTwo() throws Exception { + // set mock expectations + getMockEndpoint("mock:a").expectedMessageCount(2); + getMockEndpoint("mock:b").expectedMessageCount(2); + + // send a message + template.sendBody("direct:start", "World"); + template.sendBody("direct:start", "Camel"); + + // assert mocks + assertMockEndpointsSatisfied(); + } + + // START SNIPPET: e2 + @Override + protected RouteBuilder createRouteBuilder() { + return new RouteBuilder() { + @Override + public void configure() { + // this is the route we want to debug + from("direct:start").to("mock:a").transform(body().prepend("Hello ")).to("mock:b"); + } + }; + } + // END SNIPPET: e2 +} diff --git a/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/DebugTest.java b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/DebugTest.java new file mode 100644 index 000000000000..6bd176ec2ea6 --- /dev/null +++ b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/DebugTest.java @@ -0,0 +1,91 @@ +/* + * 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.apachencamel.quarkus.test; + +import org.apache.camel.Exchange; +import org.apache.camel.Processor; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.model.ProcessorDefinition; +import org.apache.camel.quarkus.test.CamelQuarkusTest; +import org.apache.camel.quarkus.test.CamelQuarkusTestSupport; +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@CamelQuarkusTest +public class DebugTest extends CamelQuarkusTestSupport { + + private static final Logger LOG = LoggerFactory.getLogger(DebugTest.class); + + // START SNIPPET: e1 + @Override + public boolean isUseDebugger() { + // must enable debugger + return true; + } + + @Override + protected void debugBefore( + Exchange exchange, Processor processor, ProcessorDefinition definition, String id, String shortName) { + // this method is invoked before we are about to enter the given + // processor + // from your Java editor you can just add a breakpoint in the code line + // below + LOG.info("Before " + definition + " with body " + exchange.getIn().getBody()); + } + // END SNIPPET: e1 + + @Test + public void testDebugger() throws Exception { + // set mock expectations + getMockEndpoint("mock:a").expectedMessageCount(1); + getMockEndpoint("mock:b").expectedMessageCount(1); + + // send a message + template.sendBody("direct:start", "World"); + + // assert mocks + assertMockEndpointsSatisfied(); + } + + @Test + public void testTwo() throws Exception { + // set mock expectations + getMockEndpoint("mock:a").expectedMessageCount(2); + getMockEndpoint("mock:b").expectedMessageCount(2); + + // send a message + template.sendBody("direct:start", "World"); + template.sendBody("direct:start", "Camel"); + + // assert mocks + assertMockEndpointsSatisfied(); + } + + // START SNIPPET: e2 + @Override + protected RouteBuilder createRouteBuilder() { + return new RouteBuilder() { + @Override + public void configure() { + // this is the route we want to debug + from("direct:start").to("mock:a").transform(body().prepend("Hello ")).to("mock:b"); + } + }; + } + // END SNIPPET: e2 +} diff --git a/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/FilterCreateCamelContextPerClassTest.java b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/FilterCreateCamelContextPerClassTest.java new file mode 100644 index 000000000000..dee761621ded --- /dev/null +++ b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/FilterCreateCamelContextPerClassTest.java @@ -0,0 +1,61 @@ +/* + * 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.apachencamel.quarkus.test; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.quarkus.test.CamelQuarkusTest; +import org.apache.camel.quarkus.test.CamelQuarkusTestSupport; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; + +/** + * Tests filtering using Camel Test + */ +// START SNIPPET: example +@CamelQuarkusTest +@TestInstance(TestInstance.Lifecycle.PER_CLASS) +public class FilterCreateCamelContextPerClassTest extends CamelQuarkusTestSupport { + + @Test + public void testSendMatchingMessage() throws Exception { + String expectedBody = ""; + + getMockEndpoint("mock:result").expectedBodiesReceived(expectedBody); + + template.sendBodyAndHeader("direct:start", expectedBody, "foo", "bar"); + + assertMockEndpointsSatisfied(); + } + + @Test + public void testSendNotMatchingMessage() throws Exception { + getMockEndpoint("mock:result").expectedMessageCount(0); + + template.sendBodyAndHeader("direct:start", "", "foo", "notMatchedHeaderValue"); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RouteBuilder createRouteBuilder() { + return new RouteBuilder() { + public void configure() { + from("direct:start").filter(header("foo").isEqualTo("bar")).to("mock:result"); + } + }; + } +} diff --git a/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/FilterFluentTemplateTest.java b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/FilterFluentTemplateTest.java new file mode 100644 index 000000000000..5fd9a0e79d49 --- /dev/null +++ b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/FilterFluentTemplateTest.java @@ -0,0 +1,77 @@ +/* + * 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.apachencamel.quarkus.test; + +import org.apache.camel.EndpointInject; +import org.apache.camel.FluentProducerTemplate; +import org.apache.camel.Produce; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.quarkus.test.CamelQuarkusTest; +import org.apache.camel.quarkus.test.CamelQuarkusTestSupport; +import org.junit.jupiter.api.Test; + +/** + * Tests filtering using Camel Test + */ +// START SNIPPET: example +// tag::example[] +@CamelQuarkusTest +public class FilterFluentTemplateTest extends CamelQuarkusTestSupport { + + @EndpointInject("mock:result") + protected MockEndpoint resultEndpoint; + + @Produce("direct:startFluent") + protected FluentProducerTemplate fluentTemplate; + + @Override + public boolean isDumpRouteCoverage() { + return true; + } + + @Test + public void testSendMatchingMessage() throws Exception { + String expectedBody = ""; + + resultEndpoint.expectedBodiesReceived(expectedBody); + + fluentTemplate.withBody(expectedBody).withHeader("foo", "bar").send(); + + resultEndpoint.assertIsSatisfied(); + } + + @Test + public void testSendNotMatchingMessage() throws Exception { + resultEndpoint.expectedMessageCount(0); + + fluentTemplate.withBody("").withHeader("foo", "notMatchedHeaderValue").send(); + + resultEndpoint.assertIsSatisfied(); + } + + @Override + protected RouteBuilder createRouteBuilder() { + return new RouteBuilder() { + public void configure() { + from("direct:startFluent").filter(header("foo").isEqualTo("bar")).to("mock:result"); + } + }; + } +} +// end::example[] +// END SNIPPET: example diff --git a/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/FilterJUnit5Test.java b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/FilterJUnit5Test.java new file mode 100644 index 000000000000..2c48bafb7edc --- /dev/null +++ b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/FilterJUnit5Test.java @@ -0,0 +1,71 @@ +/* + * 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.apachencamel.quarkus.test; + +import org.apache.camel.EndpointInject; +import org.apache.camel.Produce; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.quarkus.test.CamelQuarkusTest; +import org.apache.camel.quarkus.test.CamelQuarkusTestSupport; +import org.junit.jupiter.api.Test; + +/** + * Tests filtering using Camel Test + */ +// START SNIPPET: example +@CamelQuarkusTest +public class FilterJUnit5Test extends CamelQuarkusTestSupport { + + @EndpointInject("mock:result") + protected MockEndpoint resultEndpoint; + + @Produce("direct:start") + protected ProducerTemplate template; + + @Test + public void testSendMatchingMessage() throws Exception { + String expectedBody = ""; + + resultEndpoint.expectedBodiesReceived(expectedBody); + + template.sendBodyAndHeader(expectedBody, "foo", "bar"); + + resultEndpoint.assertIsSatisfied(); + } + + @Test + public void testSendNotMatchingMessage() throws Exception { + resultEndpoint.expectedMessageCount(0); + + template.sendBodyAndHeader("", "foo", "notMatchedHeaderValue"); + + resultEndpoint.assertIsSatisfied(); + } + + @Override + protected RouteBuilder createRouteBuilder() { + return new RouteBuilder() { + public void configure() { + from("direct:start").filter(header("foo").isEqualTo("bar")).to("mock:result"); + } + }; + } + +} +// END SNIPPET: example diff --git a/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/FilterTest.java b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/FilterTest.java new file mode 100644 index 000000000000..7947afc3d038 --- /dev/null +++ b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/FilterTest.java @@ -0,0 +1,77 @@ +/* + * 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.apachencamel.quarkus.test; + +import org.apache.camel.EndpointInject; +import org.apache.camel.Produce; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.quarkus.test.CamelQuarkusTest; +import org.apache.camel.quarkus.test.CamelQuarkusTestSupport; +import org.junit.jupiter.api.Test; + +/** + * Tests filtering using Camel Test + */ +// START SNIPPET: example +// tag::example[] +@CamelQuarkusTest +public class FilterTest extends CamelQuarkusTestSupport { + + @EndpointInject("mock:result") + protected MockEndpoint resultEndpoint; + + @Produce("direct:start") + protected ProducerTemplate template; + + @Override + public boolean isDumpRouteCoverage() { + return true; + } + + @Test + public void testSendMatchingMessage() throws Exception { + String expectedBody = ""; + + resultEndpoint.expectedBodiesReceived(expectedBody); + + template.sendBodyAndHeader(expectedBody, "foo", "bar"); + + resultEndpoint.assertIsSatisfied(); + } + + @Test + public void testSendNotMatchingMessage() throws Exception { + resultEndpoint.expectedMessageCount(0); + + template.sendBodyAndHeader("", "foo", "notMatchedHeaderValue"); + + resultEndpoint.assertIsSatisfied(); + } + + @Override + protected RouteBuilder createRouteBuilder() { + return new RouteBuilder() { + public void configure() { + from("direct:start").filter(header("foo").isEqualTo("bar")).to("mock:result"); + } + }; + } +} +// end::example[] +// END SNIPPET: example diff --git a/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/GetMockEndpointTest.java b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/GetMockEndpointTest.java new file mode 100644 index 000000000000..98c0350ae226 --- /dev/null +++ b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/GetMockEndpointTest.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. + */ +package org.apachencamel.quarkus.test; + +import org.apache.camel.RoutesBuilder; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.quarkus.test.CamelQuarkusTest; +import org.apache.camel.quarkus.test.CamelQuarkusTestSupport; +import org.junit.jupiter.api.Test; + +@CamelQuarkusTest +public class GetMockEndpointTest extends CamelQuarkusTestSupport { + + @Test + public void testMock() throws Exception { + getMockEndpoint("mock:result").expectedBodiesReceived("Hello World"); + + template.sendBody("direct:start", "Hello World"); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RoutesBuilder createRouteBuilder() { + return new RouteBuilder() { + @Override + public void configure() { + from("direct:start").to("mock:result?failFast=false"); + } + }; + } + +} diff --git a/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/IsMockEndpointsAndSkipJUnit5Test.java b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/IsMockEndpointsAndSkipJUnit5Test.java new file mode 100644 index 000000000000..12e582589858 --- /dev/null +++ b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/IsMockEndpointsAndSkipJUnit5Test.java @@ -0,0 +1,70 @@ +/* + * 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.apachencamel.quarkus.test; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.seda.SedaEndpoint; +import org.apache.camel.quarkus.test.CamelQuarkusTest; +import org.apache.camel.quarkus.test.CamelQuarkusTestSupport; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +// START SNIPPET: e1 +// tag::e1[] +@CamelQuarkusTest +public class IsMockEndpointsAndSkipJUnit5Test extends CamelQuarkusTestSupport { + + @Override + public String isMockEndpointsAndSkip() { + // override this method and return the pattern for which endpoints to + // mock, + // and skip sending to the original endpoint. + return "direct:foo"; + } + + @Test + public void testMockEndpointAndSkip() throws Exception { + // notice we have automatic mocked the direct:foo endpoints and the name + // of the endpoints is "mock:uri" + getMockEndpoint("mock:result").expectedBodiesReceived("Hello World"); + getMockEndpoint("mock:direct:foo").expectedMessageCount(1); + + template.sendBody("direct:start", "Hello World"); + + assertMockEndpointsSatisfied(); + + // the message was not send to the direct:foo route and thus not sent to + // the seda endpoint + SedaEndpoint seda = context.getEndpoint("seda:foo", SedaEndpoint.class); + assertEquals(0, seda.getCurrentQueueSize()); + } + + @Override + protected RouteBuilder createRouteBuilder() { + return new RouteBuilder() { + @Override + public void configure() { + from("direct:start").to("direct:foo").to("mock:result"); + + from("direct:foo").transform(constant("Bye World")).to("seda:foo"); + } + }; + } +} +// end::e1[] +// END SNIPPET: e1 diff --git a/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/IsMockEndpointsFileTest.java b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/IsMockEndpointsFileTest.java new file mode 100644 index 000000000000..27e9c827d20e --- /dev/null +++ b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/IsMockEndpointsFileTest.java @@ -0,0 +1,73 @@ +/* + * 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.apachencamel.quarkus.test; + +import org.apache.camel.Exchange; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.quarkus.test.CamelQuarkusTest; +import org.apache.camel.quarkus.test.CamelQuarkusTestSupport; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.apache.camel.test.junit5.TestSupport.deleteDirectory; + +@CamelQuarkusTest +public class IsMockEndpointsFileTest extends CamelQuarkusTestSupport { + + @Override + @BeforeEach + public void setUp() throws Exception { + deleteDirectory("target/input"); + deleteDirectory("target/messages"); + super.setUp(); + } + + @Override + public String isMockEndpoints() { + // override this method and return the pattern for which endpoints to + // mock. + return "file:target*"; + } + + @Test + public void testMockFileEndpoints() throws Exception { + // notice we have automatic mocked all endpoints and the name of the + // endpoints is "mock:uri" + MockEndpoint camel = getMockEndpoint("mock:file:target/messages/camel"); + camel.expectedMessageCount(1); + + MockEndpoint other = getMockEndpoint("mock:file:target/messages/others"); + other.expectedMessageCount(1); + + template.sendBodyAndHeader("file:target/input", "Hello Camel", Exchange.FILE_NAME, "camel.txt"); + template.sendBodyAndHeader("file:target/input", "Hello World", Exchange.FILE_NAME, "world.txt"); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RouteBuilder createRouteBuilder() { + return new RouteBuilder() { + @Override + public void configure() { + from("file:target/input").choice().when(bodyAs(String.class).contains("Camel")).to("file:target/messages/camel") + .otherwise().to("file:target/messages/others"); + } + }; + } +} diff --git a/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/IsMockEndpointsJUnit5Test.java b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/IsMockEndpointsJUnit5Test.java new file mode 100644 index 000000000000..54c2e950846e --- /dev/null +++ b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/IsMockEndpointsJUnit5Test.java @@ -0,0 +1,76 @@ +/* + * 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.apachencamel.quarkus.test; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.quarkus.test.CamelQuarkusTest; +import org.apache.camel.quarkus.test.CamelQuarkusTestSupport; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +// START SNIPPET: e1 +// tag::e1[] +@CamelQuarkusTest +public class IsMockEndpointsJUnit5Test extends CamelQuarkusTestSupport { + + @Override + public String isMockEndpoints() { + // override this method and return the pattern for which endpoints to + // mock. + // use * to indicate all + return "*"; + } + + @Test + public void testMockAllEndpoints() throws Exception { + // notice we have automatic mocked all endpoints and the name of the + // endpoints is "mock:uri" + getMockEndpoint("mock:direct:start").expectedBodiesReceived("Hello World"); + getMockEndpoint("mock:direct:foo").expectedBodiesReceived("Hello World"); + getMockEndpoint("mock:log:foo").expectedBodiesReceived("Bye World"); + getMockEndpoint("mock:result").expectedBodiesReceived("Bye World"); + + template.sendBody("direct:start", "Hello World"); + + assertMockEndpointsSatisfied(); + + // additional test to ensure correct endpoints in registry + assertNotNull(context.hasEndpoint("direct:start")); + assertNotNull(context.hasEndpoint("direct:foo")); + assertNotNull(context.hasEndpoint("log:foo")); + assertNotNull(context.hasEndpoint("mock:result")); + // all the endpoints was mocked + assertNotNull(context.hasEndpoint("mock:direct:start")); + assertNotNull(context.hasEndpoint("mock:direct:foo")); + assertNotNull(context.hasEndpoint("mock:log:foo")); + } + + @Override + protected RouteBuilder createRouteBuilder() { + return new RouteBuilder() { + @Override + public void configure() { + from("direct:start").to("direct:foo").to("log:foo").to("mock:result"); + + from("direct:foo").transform(constant("Bye World")); + } + }; + } +} +// end::e1[] +// END SNIPPET: e1 diff --git a/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/IsMockEndpointsTest.java b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/IsMockEndpointsTest.java new file mode 100644 index 000000000000..08bc20c71ce5 --- /dev/null +++ b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/IsMockEndpointsTest.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. + */ +package org.apachencamel.quarkus.test; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.quarkus.test.CamelQuarkusTest; +import org.apache.camel.quarkus.test.CamelQuarkusTestSupport; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +@CamelQuarkusTest +public class IsMockEndpointsTest extends CamelQuarkusTestSupport { + + @Override + public String isMockEndpoints() { + return "*"; + } + + @Test + public void testMockAllEndpoints() throws Exception { + getMockEndpoint("mock:direct:start").expectedBodiesReceived("Hello World"); + getMockEndpoint("mock:direct:foo").expectedBodiesReceived("Hello World"); + getMockEndpoint("mock:log:foo").expectedBodiesReceived("Bye World"); + getMockEndpoint("mock:result").expectedBodiesReceived("Bye World"); + + template.sendBody("direct:start", "Hello World"); + + assertMockEndpointsSatisfied(); + + // additional test to ensure correct endpoints in registry + assertNotNull(context.hasEndpoint("direct:start")); + assertNotNull(context.hasEndpoint("direct:foo")); + assertNotNull(context.hasEndpoint("log:foo")); + assertNotNull(context.hasEndpoint("mock:result")); + // all the endpoints was mocked + assertNotNull(context.hasEndpoint("mock:direct:start")); + assertNotNull(context.hasEndpoint("mock:direct:foo")); + assertNotNull(context.hasEndpoint("mock:log:foo")); + } + + @Override + protected RouteBuilder createRouteBuilder() { + return new 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-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/MockEndpointFailNoHeaderTest.java b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/MockEndpointFailNoHeaderTest.java new file mode 100644 index 000000000000..2eb628aab4ca --- /dev/null +++ b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/MockEndpointFailNoHeaderTest.java @@ -0,0 +1,65 @@ +/* + * 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.apachencamel.quarkus.test; + +import org.apache.camel.EndpointInject; +import org.apache.camel.Produce; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.quarkus.test.CamelQuarkusTest; +import org.apache.camel.quarkus.test.CamelQuarkusTestSupport; +import org.junit.jupiter.api.Test; + +@CamelQuarkusTest +public class MockEndpointFailNoHeaderTest extends CamelQuarkusTestSupport { + + @EndpointInject("mock:result") + protected MockEndpoint resultEndpoint; + + @Produce("direct:start") + protected ProducerTemplate template; + + @Override + public boolean isDumpRouteCoverage() { + return true; + } + + @Test + public void withHeaderTestCase() throws InterruptedException { + String expectedBody = ""; + resultEndpoint.expectedHeaderReceived("foo", "bar"); + template.sendBodyAndHeader(expectedBody, "foo", "bar"); + resultEndpoint.assertIsSatisfied(); + } + + @Test + public void noHeaderTestCase() throws InterruptedException { + resultEndpoint.expectedHeaderReceived("foo", "bar"); + resultEndpoint.setResultWaitTime(1); // speedup test + resultEndpoint.assertIsNotSatisfied(); + } + + @Override + protected RouteBuilder createRouteBuilder() { + return new RouteBuilder() { + public void configure() { + from("direct:start").filter(header("foo").isEqualTo("bar")).to("mock:result"); + } + }; + } +} diff --git a/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/MyProduceBean.java b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/MyProduceBean.java new file mode 100644 index 000000000000..978c134e8564 --- /dev/null +++ b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/MyProduceBean.java @@ -0,0 +1,32 @@ +/* + * 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.apachencamel.quarkus.test; + +import org.apache.camel.Produce; + +/** + * + */ +public class MyProduceBean { + + @Produce("mock:result") + MySender sender; + + public void doSomething(String body) { + sender.send(body); + } +} diff --git a/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/MySender.java b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/MySender.java new file mode 100644 index 000000000000..29212acd0fc6 --- /dev/null +++ b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/MySender.java @@ -0,0 +1,25 @@ +/* + * 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.apachencamel.quarkus.test; + +/** + * + */ +public interface MySender { + + void send(String body); +} diff --git a/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/ProduceBeanTest.java b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/ProduceBeanTest.java new file mode 100644 index 000000000000..0a98b42ad4fb --- /dev/null +++ b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/ProduceBeanTest.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.apachencamel.quarkus.test; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.quarkus.test.CamelQuarkusTest; +import org.apache.camel.quarkus.test.CamelQuarkusTestSupport; +import org.junit.jupiter.api.Test; + +@CamelQuarkusTest +public class ProduceBeanTest extends CamelQuarkusTestSupport { + + @Test + public void testProduceBean() throws Exception { + getMockEndpoint("mock:result").expectedMessageCount(1); + + template.sendBody("direct:start", "Hello World"); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RouteBuilder createRouteBuilder() { + return new RouteBuilder() { + @Override + public void configure() { + from("direct:start").bean(MyProduceBean.class, "doSomething"); + } + }; + } +} diff --git a/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/RouteBuilderConfigureExceptionTest.java b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/RouteBuilderConfigureExceptionTest.java new file mode 100644 index 000000000000..447a752d4c03 --- /dev/null +++ b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/RouteBuilderConfigureExceptionTest.java @@ -0,0 +1,56 @@ +/* + * 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.apachencamel.quarkus.test; + +import org.apache.camel.Predicate; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.quarkus.test.CamelQuarkusTest; +import org.apache.camel.quarkus.test.CamelQuarkusTestSupport; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.fail; + +@CamelQuarkusTest +public class RouteBuilderConfigureExceptionTest extends CamelQuarkusTestSupport { + + private Predicate iAmNull; + + @Override + @BeforeEach + public void setUp() { + try { + super.setUp(); + fail("Should have thrown exception"); + } catch (Exception e) { + // expected + } + } + + @Test + public void testFoo() { + } + + @Override + protected RouteBuilder createRouteBuilder() { + return new RouteBuilder() { + public void configure() { + from("direct:start").choice().when(iAmNull).to("mock:dead"); + } + }; + } +} diff --git a/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/RouteProcessorDumpRouteCoverageTest.java b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/RouteProcessorDumpRouteCoverageTest.java new file mode 100644 index 000000000000..2f01372efcf2 --- /dev/null +++ b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/RouteProcessorDumpRouteCoverageTest.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.apachencamel.quarkus.test; + +import org.apache.camel.RoutesBuilder; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.quarkus.test.CamelQuarkusTest; +import org.apache.camel.quarkus.test.CamelQuarkusTestSupport; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.TestReporter; + +import static org.apache.camel.test.junit5.TestSupport.assertFileExists; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +@CamelQuarkusTest +@Disabled // jmx has to be investigated +public class RouteProcessorDumpRouteCoverageTest extends CamelQuarkusTestSupport { + + @Override + public boolean isDumpRouteCoverage() { + return true; + } + + @Test + public void testProcessorJunit5() { + String out = template.requestBody("direct:start", "Hello World", String.class); + assertEquals("Bye World", out); + } + + @Test + public void testProcessorJunit5WithTestParameterInjection(TestInfo info, TestReporter testReporter) { + assertNotNull(info); + assertNotNull(testReporter); + String out = template.requestBody("direct:start", "Hello World", String.class); + assertEquals("Bye World", out); + } + + @AfterAll + @Disabled + public static void checkDumpFilesCreatedAfterTests() { + // should create that file when test is done + assertFileExists("target/camel-route-coverage/RouteProcessorDumpRouteCoverageTest-testProcessorJunit5.xml"); + assertFileExists( + "target/camel-route-coverage/RouteProcessorDumpRouteCoverageTest-testProcessorJunit5WithTestParameterInjection.xml"); + } + + @Override + protected RoutesBuilder createRouteBuilder() { + return new RouteBuilder() { + @Override + public void configure() { + from("direct:start").process(exchange -> exchange.getMessage().setBody("Bye World")); + } + }; + } + +} diff --git a/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/SimpleMockEndpointsTest.java b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/SimpleMockEndpointsTest.java new file mode 100644 index 000000000000..cf6334d436ed --- /dev/null +++ b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/SimpleMockEndpointsTest.java @@ -0,0 +1,57 @@ +/* + * 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.apachencamel.quarkus.test; + +import org.apache.camel.Produce; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.RoutesBuilder; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.quarkus.test.CamelQuarkusTest; +import org.apache.camel.quarkus.test.CamelQuarkusTestSupport; +import org.junit.jupiter.api.Test; + +@CamelQuarkusTest +public class SimpleMockEndpointsTest extends CamelQuarkusTestSupport { + + @Produce("direct:start") + protected ProducerTemplate template; + + @Override + public String isMockEndpointsAndSkip() { + return "seda:queue"; + } + + @Test + public void testMockAndSkip() throws Exception { + getMockEndpoint("mock:seda:queue").expectedBodiesReceived("Bye Camel"); + + template.sendBody("seda:start", "Camel"); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RoutesBuilder createRouteBuilder() { + return new RouteBuilder() { + @Override + public void configure() { + from("seda:start").transform(simple("Bye ${body}")).to("seda:queue"); + } + }; + } + +} diff --git a/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/SimpleMockTest.java b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/SimpleMockTest.java new file mode 100644 index 000000000000..2176f3389cf9 --- /dev/null +++ b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/SimpleMockTest.java @@ -0,0 +1,53 @@ +/* + * 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.apachencamel.quarkus.test; + +import org.apache.camel.Produce; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.RoutesBuilder; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.quarkus.test.CamelQuarkusTest; +import org.apache.camel.quarkus.test.CamelQuarkusTestSupport; +import org.junit.jupiter.api.Test; + +@CamelQuarkusTest +public class SimpleMockTest extends CamelQuarkusTestSupport { + + @Produce("direct:start") + // @Inject + protected ProducerTemplate template; + + @Test + public void testMock() throws Exception { + getMockEndpoint("mock:result").expectedBodiesReceived("Hello World"); + + template.sendBody("direct:start", "Hello World"); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RoutesBuilder createRouteBuilder() { + return new RouteBuilder() { + @Override + public void configure() { + from("direct:start").to("mock:result"); + } + }; + } + +} diff --git a/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/SimpleNotifyBuilderTest.java b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/SimpleNotifyBuilderTest.java new file mode 100644 index 000000000000..98af4067e953 --- /dev/null +++ b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/SimpleNotifyBuilderTest.java @@ -0,0 +1,55 @@ +/* + * 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.apachencamel.quarkus.test; + +import java.util.concurrent.TimeUnit; + +import org.apache.camel.RoutesBuilder; +import org.apache.camel.builder.NotifyBuilder; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.quarkus.test.CamelQuarkusTest; +import org.apache.camel.quarkus.test.CamelQuarkusTestSupport; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +@CamelQuarkusTest +public class SimpleNotifyBuilderTest extends CamelQuarkusTestSupport { + + @Test + public void testNotifyBuilder() { + NotifyBuilder notify = new NotifyBuilder(context).from("seda:start").wereSentTo("seda:queue").whenDone(10).create(); + + for (int i = 0; i < 10; i++) { + template.sendBody("seda:start", "Camel" + i); + } + + boolean matches = notify.matches(10, TimeUnit.SECONDS); + assertTrue(matches); + } + + @Override + protected RoutesBuilder createRouteBuilder() { + return new RouteBuilder() { + @Override + public void configure() { + from("seda:start").transform(simple("Bye ${body}")).to("seda:queue"); + } + }; + } + +} diff --git a/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/SimpleWeaveAddMockLastTest.java b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/SimpleWeaveAddMockLastTest.java new file mode 100644 index 000000000000..feaa0567f915 --- /dev/null +++ b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/SimpleWeaveAddMockLastTest.java @@ -0,0 +1,63 @@ +/* + * 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.apachencamel.quarkus.test; + +import org.apache.camel.RoutesBuilder; +import org.apache.camel.builder.AdviceWith; +import org.apache.camel.builder.AdviceWithRouteBuilder; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.model.Model; +import org.apache.camel.quarkus.test.CamelQuarkusTest; +import org.apache.camel.quarkus.test.CamelQuarkusTestSupport; +import org.junit.jupiter.api.Test; + +@CamelQuarkusTest +public class SimpleWeaveAddMockLastTest extends CamelQuarkusTestSupport { + + public boolean isUseAdviceWith() { + return true; + } + + @Test + public void testWeaveAddMockLast() throws Exception { + AdviceWith.adviceWith(context.getExtension(Model.class).getRouteDefinitions().get(0), context, + new AdviceWithRouteBuilder() { + @Override + public void configure() { + weaveAddLast().to("mock:result"); + } + }); + context.start(); + + getMockEndpoint("mock:result").expectedBodiesReceived("Bye Camel"); + + template.sendBody("seda:start", "Camel"); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RoutesBuilder createRouteBuilder() { + return new RouteBuilder() { + @Override + public void configure() { + from("seda:start").transform(simple("Bye ${body}")).to("seda:queue"); + } + }; + } + +} diff --git a/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/UseOverridePropertiesWithPropertiesComponentTest.java b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/UseOverridePropertiesWithPropertiesComponentTest.java new file mode 100644 index 000000000000..b4ba955dc49b --- /dev/null +++ b/integration-tests-support/test-support-jvm/src/test/java/org/apachencamel/quarkus/test/UseOverridePropertiesWithPropertiesComponentTest.java @@ -0,0 +1,79 @@ +/* + * 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.apachencamel.quarkus.test; + +import java.util.Properties; + +import org.apache.camel.builder.AdviceWith; +import org.apache.camel.builder.AdviceWithRouteBuilder; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.model.Model; +import org.apache.camel.quarkus.test.CamelQuarkusTest; +import org.apache.camel.quarkus.test.CamelQuarkusTestSupport; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +@CamelQuarkusTest +public class UseOverridePropertiesWithPropertiesComponentTest extends CamelQuarkusTestSupport { + + @Override + public boolean isUseAdviceWith() { + return true; + } + + @BeforeEach + public void doSomethingBefore() throws Exception { + AdviceWithRouteBuilder mocker = new AdviceWithRouteBuilder() { + @Override + public void configure() throws Exception { + replaceFromWith("direct:sftp"); + + interceptSendToEndpoint("file:*").skipSendToOriginalEndpoint().to("mock:file"); + } + }; + AdviceWith.adviceWith(context.getExtension(Model.class).getRouteDefinition("myRoute"), context, mocker); + } + + @Override + protected Properties useOverridePropertiesWithPropertiesComponent() { + Properties pc = new Properties(); + pc.put("ftp.username", "scott"); + pc.put("ftp.password", "tiger"); + return pc; + } + + @Test + public void testOverride() throws Exception { + context.start(); + + getMockEndpoint("mock:file").expectedMessageCount(1); + + template.sendBody("direct:sftp", "Hello World"); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RouteBuilder createRouteBuilder() { + return new RouteBuilder() { + public void configure() { + from("ftp:somepath?username={{ftp.username}}&password={{ftp.password}}").routeId("myRoute") + .to("file:target/out"); + } + }; + } +} diff --git a/poms/bom-test/pom.xml b/poms/bom-test/pom.xml index a74c3286574a..1f56fcdebcb4 100644 --- a/poms/bom-test/pom.xml +++ b/poms/bom-test/pom.xml @@ -117,6 +117,7 @@ camel-quarkus-integration-test-support ${camel-quarkus.version} + org.apache.camel.quarkus camel-quarkus-integration-test-support-mock-backend @@ -354,6 +355,7 @@ test + diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml index 9df32e6c0756..24e95401c0fc 100644 --- a/poms/bom/pom.xml +++ b/poms/bom/pom.xml @@ -5359,6 +5359,12 @@ + + + org.apache.camel + camel-test-junit5 + ${camel.version} + org.apache.camel camel-tooling-model @@ -7240,6 +7246,11 @@ camel-quarkus-influxdb-deployment ${camel-quarkus.version} + + org.apache.camel.quarkus + camel-quarkus-integration-test-support-jvm + ${camel-quarkus.version} + org.apache.camel.quarkus camel-quarkus-iota @@ -8815,6 +8826,7 @@ camel-quarkus-telegram-deployment ${camel-quarkus.version} + org.apache.camel.quarkus camel-quarkus-threadpoolfactory-vertx @@ -10172,92 +10184,92 @@ - - org.l2x6.cq - cq-maven-plugin - - - flatten-bom - - flatten-bom - - process-resources - - - - - - io.quarkus:quarkus-bom - - - - - - org.apache.camel.quarkus:* - ca.uhn.hapi:* - net.openhft:affinity - - - - org.amqphub.quarkus:quarkus-qpid-jms - org.apache.geronimo.specs:geronimo-jms_2.0_spec - - - com.datastax.oss:java-driver-core - com.google.code.findbugs:jsr305 - - - com.datastax.oss:java-driver-query-builder - com.google.code.findbugs:jsr305 - - - io.quarkiverse.minio:quarkus-minio - com.google.code.findbugs:jsr305 - - - software.amazon.awssdk:apache-client - commons-logging:commons-logging - - - io.debezium:debezium-embedded:1.6.1.Final:jar - javax.activation:activation,javax.servlet:javax.servlet-api,log4j:log4j,org.apache.kafka:kafka-log4j-appender,org.apache.kafka:connect-runtime,org.apache.kafka:connect-file - - - org.glassfish.jaxb:jaxb-runtime - jakarta.xml.bind:jakarta.xml.bind-api - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - com.google.http-client:google-http-client - com.google.code.findbugs:jsr305 - - - io.debezium:debezium-embedded - javax.ws.rs:javax.ws.rs-api - - - io.grpc:grpc-netty - com.google.code.findbugs:jsr305 - - - org.apache.httpcomponents:* - commons-logging:commons-logging - - - org.apache.kafka:connect-runtime - javax.activation:activation,javax.servlet:javax.servlet-api,log4j:log4j - - - com.fasterxml.jackson.module:jackson-module-jaxb-annotations - jakarta.activation:jakarta.activation-api,jakarta.xml.bind:jakarta.xml.bind-api - + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + +