This is an automated email from the ASF dual-hosted git repository.

ppalaga pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git

commit 65d762f7a56579b0fbb3982b76c1be031deed05c
Author: Peter Palaga <[email protected]>
AuthorDate: Wed May 12 22:14:41 2021 +0200

    Support @Consume #2580
---
 docs/modules/ROOT/pages/user-guide/cdi.adoc        |  41 ++++
 .../quarkus/core/deployment/ConsumeProcessor.java  | 233 +++++++++++++++++++++
 .../apache/camel/quarkus/core/ConsumeRecorder.java |  53 +++++
 .../bean/{ => consume}/ConsumeAnnotationBean.java  |   4 +-
 .../CustomNamedConsumeAnnotationBean.java}         |  13 +-
 .../DefaultNamedConsumeAnnotationBean.java}        |  13 +-
 .../SingletonAnnotationBean.java}                  |  13 +-
 .../camel/quarkus/component/bean/BeanTest.java     |  12 --
 .../component/bean/ConsumeAnnotationIT.java}       |  14 +-
 .../component/bean/ConsumeAnnotationTest.java      |  67 ++++++
 10 files changed, 423 insertions(+), 40 deletions(-)

diff --git a/docs/modules/ROOT/pages/user-guide/cdi.adoc 
b/docs/modules/ROOT/pages/user-guide/cdi.adoc
index 8d05098..181d2fa 100644
--- a/docs/modules/ROOT/pages/user-guide/cdi.adoc
+++ b/docs/modules/ROOT/pages/user-guide/cdi.adoc
@@ -69,6 +69,7 @@ public static class MyBean {
 
 If you are used to `@org.apache.camel.EndpointInject` and 
`@org.apache.camel.Produce` from
 xref:latest@manual::pojo-producing.adoc[plain Camel] or from Camel on 
SpringBoot, you can continue using them on Quarkus too.
+This is supported since Camel Quarkus 1.9.0.
 
 The following use cases are supported by 
`org.apache.camel.quarkus:camel-quarkus-core`:
 
@@ -169,7 +170,47 @@ public class CamelRoute extends RouteBuilder {
     @Override
     public void configure() {
         from("direct:named")
+                .bean("namedBean", "hello");
+        /* ... which is an equivalent of the following: */
+        from("direct:named")
                 .to("bean:namedBean?method=hello");
     }
 }
 ----
+
+[INFO]
+====
+We aim at supporting all use cases listed in 
xref:latest@manual::bean-binding.adoc[Bean binding] section of Camel 
documentation.
+Do not hesitate to https://github.com/apache/camel-quarkus/issues[file an 
issue] if some bean binding scenario does not work for you.
+====
+
+=== `@Consume`
+
+Since Camel Quarkus 1.9.0, the `camel-quarkus-bean` artifact brings support 
for `@org.apache.camel.Consume`
+- see the https://camel.apache.org/manual/latest/pojo-consuming.html[Pojo 
consuming] section of Camel documentation.
+
+Declaring a class like the following
+
+[source,java]
+----
+import org.apache.camel.Consume;
+public class Foo {
+
+  @Consume("activemq:cheese")
+  public void onCheese(String name) {
+    ...
+  }
+}
+----
+
+will automatically create the following Camel route
+
+[source,java]
+----
+from("activemq:cheese").bean("foo1234", "onCheese")
+----
+
+for you.
+Note that Camel Quarkus will implicitly add `@javax.inject.Singleton` and 
`javax.inject.Named("foo1234")` to the bean class, where `1234` is a hash code 
obtained from the fully qualified class name.
+If your bean has some CDI scope (such as `@ApplicationScoped`) or 
`@Named("someName")` set already,
+those will be honored in the auto-created route.
diff --git 
a/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/ConsumeProcessor.java
 
b/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/ConsumeProcessor.java
new file mode 100644
index 0000000..4c979db
--- /dev/null
+++ 
b/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/ConsumeProcessor.java
@@ -0,0 +1,233 @@
+/*
+ * 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 java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.decorator.Decorator;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.context.ConversationScoped;
+import javax.enterprise.context.Dependent;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.inject.spi.Interceptor;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import io.quarkus.arc.deployment.AnnotationsTransformerBuildItem;
+import io.quarkus.arc.deployment.UnremovableBeanBuildItem;
+import io.quarkus.arc.processor.AnnotationsTransformer;
+import io.quarkus.arc.processor.Transformation;
+import io.quarkus.deployment.annotations.BuildProducer;
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.annotations.ExecutionTime;
+import io.quarkus.deployment.annotations.Record;
+import io.quarkus.deployment.builditem.CapabilityBuildItem;
+import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
+import io.quarkus.runtime.RuntimeValue;
+import org.apache.camel.Consume;
+import org.apache.camel.model.RoutesDefinition;
+import org.apache.camel.quarkus.core.ConsumeRecorder;
+import org.apache.camel.quarkus.core.deployment.spi.CamelContextBuildItem;
+import org.apache.camel.quarkus.support.common.CamelCapabilities;
+import org.jboss.jandex.AnnotationInstance;
+import org.jboss.jandex.AnnotationTarget;
+import org.jboss.jandex.AnnotationTarget.Kind;
+import org.jboss.jandex.AnnotationValue;
+import org.jboss.jandex.ClassInfo;
+import org.jboss.jandex.DotName;
+import org.jboss.jandex.MethodInfo;
+
+/**
+ * Support for Camel {@link Consume} annotation.
+ */
+public class ConsumeProcessor {
+
+    private static final DotName CONSUME_ANNOTATION = 
DotName.createSimple(Consume.class.getName());
+    private static final DotName NAMED_ANNOTATION = 
DotName.createSimple(Named.class.getName());
+    /**
+     * Based on 
https://docs.jboss.org/cdi/spec/2.0/cdi-spec.html#builtin_scopes
+     * the list is not 100% complete, but hopefully it will suffice for our 
purposes
+     */
+    public static final Set<DotName> BEAN_DEFINING_ANNOTATIONS = new 
HashSet<DotName>(Arrays.asList(
+            DotName.createSimple(ApplicationScoped.class.getName()),
+            DotName.createSimple(SessionScoped.class.getName()),
+            DotName.createSimple(ConversationScoped.class.getName()),
+            DotName.createSimple(RequestScoped.class.getName()),
+            DotName.createSimple(Interceptor.class.getName()),
+            DotName.createSimple(Decorator.class.getName()),
+            DotName.createSimple(Dependent.class.getName()),
+            DotName.createSimple(Singleton.class.getName())));
+
+    @BuildStep
+    void annotationsTransformers(
+            BuildProducer<AnnotationsTransformerBuildItem> 
annotationsTransformers) {
+
+        annotationsTransformers.produce(new 
AnnotationsTransformerBuildItem(new AnnotationsTransformer() {
+
+            public boolean appliesTo(org.jboss.jandex.AnnotationTarget.Kind 
kind) {
+                return kind == Kind.CLASS;
+            }
+
+            @Override
+            public void transform(TransformationContext ctx) {
+                final ClassInfo classInfo = ctx.getTarget().asClass();
+                if (hasConsumeMethod(classInfo)) {
+                    /* If there is @Consume on a method, make the declaring 
class a named injectable bean */
+                    String beanName = namedValue(classInfo);
+                    final Transformation transform = ctx.transform();
+                    if 
(!classInfo.annotations().keySet().stream().anyMatch(BEAN_DEFINING_ANNOTATIONS::contains))
 {
+                        /* Only add @Singleton if there is no other bean 
defining annotation yet */
+                        transform.add(Singleton.class);
+                    }
+
+                    if (beanName == null) {
+                        beanName = ConsumeProcessor.uniqueBeanName(classInfo);
+                        transform.add(Named.class, 
AnnotationValue.createStringValue("value", beanName));
+                    }
+
+                    transform.done();
+                }
+            }
+        }));
+
+    }
+
+    static String namedValue(ClassInfo classInfo) {
+        String beanName = null;
+        final AnnotationInstance named = 
classInfo.classAnnotation(NAMED_ANNOTATION);
+        if (named != null) {
+            if (named.value() != null) {
+                beanName = named.value().asString();
+            }
+            if (beanName == null) {
+                /* default bean name */
+                beanName = ConsumeProcessor.firstLower(classInfo.simpleName());
+            }
+        }
+        return beanName;
+    }
+
+    static boolean hasConsumeMethod(ClassInfo classInfo) {
+        for (MethodInfo methodInfo : classInfo.methods()) {
+            if (methodInfo.annotation(CONSUME_ANNOTATION) != null) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    @Record(value = ExecutionTime.RUNTIME_INIT)
+    @BuildStep
+    void generateConsumeRoutes(
+            ConsumeRecorder recorder,
+            CombinedIndexBuildItem index,
+            List<CapabilityBuildItem> capabilities,
+            CamelContextBuildItem camelContext) {
+
+        final Collection<AnnotationInstance> consumeAnnotations = 
index.getIndex().getAnnotations(CONSUME_ANNOTATION);
+        if (!consumeAnnotations.isEmpty()) {
+            final RuntimeValue<RoutesDefinition> routesDefinition = 
recorder.createRoutesDefinition();
+
+            final boolean beanCapabilityAvailable = 
capabilities.stream().map(CapabilityBuildItem::getName)
+                    .anyMatch(feature -> 
CamelCapabilities.BEAN.equals(feature));
+
+            for (AnnotationInstance annot : consumeAnnotations) {
+                final AnnotationTarget target = annot.target();
+                switch (target.kind()) {
+                case METHOD: {
+                    final MethodInfo methodInfo = target.asMethod();
+                    final String uri = annot.value().asString();
+                    final ClassInfo declaringClass = 
methodInfo.declaringClass();
+                    if (uri.isEmpty()) {
+                        throw new IllegalStateException("@" + 
Consume.class.getName()
+                                + " requires a Camel endpoint URI in its 
value, e.g. @Consume(\"direct:myDirect\"): "
+                                + methodInfo
+                                + " in " + declaringClass.name());
+                    }
+                    if (!beanCapabilityAvailable) {
+                        throw new IllegalStateException(
+                                "Add camel-quarkus-bean dependency to be able 
to use @" + Consume.class.getName()
+                                        + " on method:"
+                                        + methodInfo
+                                        + " in " + declaringClass.name());
+                    }
+                    String beanName = namedValue(declaringClass);
+                    if (beanName == null) {
+                        beanName = 
ConsumeProcessor.uniqueBeanName(declaringClass);
+                    }
+                    recorder.addConsumeRoute(routesDefinition, uri, beanName, 
methodInfo.name());
+                    break;
+                }
+                default:
+                    throw new IllegalStateException("Expected method, got " + 
target.kind() + ": " + target);
+                }
+            }
+            recorder.addConsumeRoutesToContext(camelContext.getCamelContext(), 
routesDefinition);
+        }
+    }
+
+    @BuildStep
+    void unremovables(
+            CombinedIndexBuildItem index,
+            BuildProducer<UnremovableBeanBuildItem> unremovables,
+            BuildProducer<ReflectiveClassBuildItem> reflectiveClasses) {
+
+        final Collection<AnnotationInstance> consumeAnnotations = 
index.getIndex().getAnnotations(CONSUME_ANNOTATION);
+        if (!consumeAnnotations.isEmpty()) {
+            final Set<DotName> declaringClasses = new LinkedHashSet<DotName>();
+            for (AnnotationInstance annot : consumeAnnotations) {
+                final AnnotationTarget target = annot.target();
+                switch (target.kind()) {
+                case METHOD: {
+                    final MethodInfo methodInfo = target.asMethod();
+                    declaringClasses.add(methodInfo.declaringClass().name());
+                    break;
+                }
+                default:
+                    throw new IllegalStateException("Expected method, got " + 
target.kind() + ": " + target);
+                }
+            }
+            
unremovables.produce(UnremovableBeanBuildItem.beanTypes(declaringClasses));
+
+            reflectiveClasses.produce(
+                    new ReflectiveClassBuildItem(
+                            true,
+                            false,
+                            declaringClasses.stream()
+                                    .map(DotName::toString)
+                                    .toArray(String[]::new)));
+        }
+    }
+
+    static String uniqueBeanName(ClassInfo classInfo) {
+        return firstLower(classInfo.simpleName()) + 
classInfo.name().hashCode();
+    }
+
+    static String firstLower(String str) {
+        char c[] = str.toCharArray();
+        c[0] = Character.toLowerCase(c[0]);
+        return new String(c);
+    }
+
+}
diff --git 
a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/ConsumeRecorder.java
 
b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/ConsumeRecorder.java
new file mode 100644
index 0000000..370ff7a
--- /dev/null
+++ 
b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/ConsumeRecorder.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.apache.camel.quarkus.core;
+
+import io.quarkus.runtime.RuntimeValue;
+import io.quarkus.runtime.annotations.Recorder;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Consume;
+import org.apache.camel.model.Model;
+import org.apache.camel.model.RoutesDefinition;
+
+/**
+ * Support for Camel {@link Consume} annotation.
+ */
+@Recorder
+public class ConsumeRecorder {
+
+    public RuntimeValue<RoutesDefinition> createRoutesDefinition() {
+        final RoutesDefinition routesDefinition = new RoutesDefinition();
+        return new RuntimeValue<RoutesDefinition>(routesDefinition);
+    }
+
+    public void addConsumeRoute(RuntimeValue<RoutesDefinition> 
routesDefinition, String uri, String beanName, String method) {
+        final RoutesDefinition routes = routesDefinition.getValue();
+        routes.from(uri).bean(beanName, method);
+    }
+
+    public void addConsumeRoutesToContext(RuntimeValue<CamelContext> 
camelContext,
+            RuntimeValue<RoutesDefinition> routesDefinition) {
+        try {
+            final RoutesDefinition routes = routesDefinition.getValue();
+            routes.setCamelContext(camelContext.getValue());
+            
camelContext.getValue().getExtension(Model.class).addRouteDefinitions(routes.getRoutes());
+        } catch (Exception e) {
+            throw new RuntimeException("Could not add routes to context", e);
+        }
+    }
+
+}
diff --git 
a/integration-tests/bean/src/main/java/org/apache/camel/quarkus/component/bean/ConsumeAnnotationBean.java
 
b/integration-tests/bean/src/main/java/org/apache/camel/quarkus/component/bean/consume/ConsumeAnnotationBean.java
similarity index 89%
copy from 
integration-tests/bean/src/main/java/org/apache/camel/quarkus/component/bean/ConsumeAnnotationBean.java
copy to 
integration-tests/bean/src/main/java/org/apache/camel/quarkus/component/bean/consume/ConsumeAnnotationBean.java
index 2119785..23e56ac 100644
--- 
a/integration-tests/bean/src/main/java/org/apache/camel/quarkus/component/bean/ConsumeAnnotationBean.java
+++ 
b/integration-tests/bean/src/main/java/org/apache/camel/quarkus/component/bean/consume/ConsumeAnnotationBean.java
@@ -14,12 +14,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.quarkus.component.bean;
+package org.apache.camel.quarkus.component.bean.consume;
 
 import org.apache.camel.Consume;
 
 /**
- * A bean annotated with {@code @Consume}
+ * A bean having a method annotated with {@code @Consume}
  */
 public class ConsumeAnnotationBean {
 
diff --git 
a/integration-tests/bean/src/main/java/org/apache/camel/quarkus/component/bean/ConsumeAnnotationBean.java
 
b/integration-tests/bean/src/main/java/org/apache/camel/quarkus/component/bean/consume/CustomNamedConsumeAnnotationBean.java
similarity index 71%
copy from 
integration-tests/bean/src/main/java/org/apache/camel/quarkus/component/bean/ConsumeAnnotationBean.java
copy to 
integration-tests/bean/src/main/java/org/apache/camel/quarkus/component/bean/consume/CustomNamedConsumeAnnotationBean.java
index 2119785..bdf4a73 100644
--- 
a/integration-tests/bean/src/main/java/org/apache/camel/quarkus/component/bean/ConsumeAnnotationBean.java
+++ 
b/integration-tests/bean/src/main/java/org/apache/camel/quarkus/component/bean/consume/CustomNamedConsumeAnnotationBean.java
@@ -14,18 +14,21 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.quarkus.component.bean;
+package org.apache.camel.quarkus.component.bean.consume;
+
+import javax.inject.Named;
 
 import org.apache.camel.Consume;
 
 /**
- * A bean annotated with {@code @Consume}
+ * A {@code @Named} bean a specific name having a method annotated with {@code 
@Consume}
  */
-public class ConsumeAnnotationBean {
+@Named("myCustomNamedConsumeAnnotation")
+public class CustomNamedConsumeAnnotationBean {
 
-    @Consume("direct:consumeAnnotation")
+    @Consume("direct:customNamedConsumeAnnotation")
     public String consumeAnnotation(String name) {
-        return "Consumed " + name;
+        return "Consumed custom named " + name;
     }
 
 }
diff --git 
a/integration-tests/bean/src/main/java/org/apache/camel/quarkus/component/bean/ConsumeAnnotationBean.java
 
b/integration-tests/bean/src/main/java/org/apache/camel/quarkus/component/bean/consume/DefaultNamedConsumeAnnotationBean.java
similarity index 73%
copy from 
integration-tests/bean/src/main/java/org/apache/camel/quarkus/component/bean/ConsumeAnnotationBean.java
copy to 
integration-tests/bean/src/main/java/org/apache/camel/quarkus/component/bean/consume/DefaultNamedConsumeAnnotationBean.java
index 2119785..64f4fe9 100644
--- 
a/integration-tests/bean/src/main/java/org/apache/camel/quarkus/component/bean/ConsumeAnnotationBean.java
+++ 
b/integration-tests/bean/src/main/java/org/apache/camel/quarkus/component/bean/consume/DefaultNamedConsumeAnnotationBean.java
@@ -14,18 +14,21 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.quarkus.component.bean;
+package org.apache.camel.quarkus.component.bean.consume;
+
+import javax.inject.Named;
 
 import org.apache.camel.Consume;
 
 /**
- * A bean annotated with {@code @Consume}
+ * A {@code @Named} with no specific name bean having a method annotated with 
{@code @Consume}
  */
-public class ConsumeAnnotationBean {
+@Named
+public class DefaultNamedConsumeAnnotationBean {
 
-    @Consume("direct:consumeAnnotation")
+    @Consume("direct:defaultNamedConsumeAnnotation")
     public String consumeAnnotation(String name) {
-        return "Consumed " + name;
+        return "Consumed named " + name;
     }
 
 }
diff --git 
a/integration-tests/bean/src/main/java/org/apache/camel/quarkus/component/bean/ConsumeAnnotationBean.java
 
b/integration-tests/bean/src/main/java/org/apache/camel/quarkus/component/bean/consume/SingletonAnnotationBean.java
similarity index 73%
copy from 
integration-tests/bean/src/main/java/org/apache/camel/quarkus/component/bean/ConsumeAnnotationBean.java
copy to 
integration-tests/bean/src/main/java/org/apache/camel/quarkus/component/bean/consume/SingletonAnnotationBean.java
index 2119785..7c17012 100644
--- 
a/integration-tests/bean/src/main/java/org/apache/camel/quarkus/component/bean/ConsumeAnnotationBean.java
+++ 
b/integration-tests/bean/src/main/java/org/apache/camel/quarkus/component/bean/consume/SingletonAnnotationBean.java
@@ -14,18 +14,21 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.quarkus.component.bean;
+package org.apache.camel.quarkus.component.bean.consume;
+
+import javax.inject.Singleton;
 
 import org.apache.camel.Consume;
 
 /**
- * A bean annotated with {@code @Consume}
+ * A bean annotated with {@link Singleton} having a method annotated with 
{@code @Consume}
  */
-public class ConsumeAnnotationBean {
+@Singleton
+public class SingletonAnnotationBean {
 
-    @Consume("direct:consumeAnnotation")
+    @Consume("direct:singletonConsumeAnnotation")
     public String consumeAnnotation(String name) {
-        return "Consumed " + name;
+        return "Consumed singleton " + name;
     }
 
 }
diff --git 
a/integration-tests/bean/src/test/java/org/apache/camel/quarkus/component/bean/BeanTest.java
 
b/integration-tests/bean/src/test/java/org/apache/camel/quarkus/component/bean/BeanTest.java
index 1981f21..5d8c2c2 100644
--- 
a/integration-tests/bean/src/test/java/org/apache/camel/quarkus/component/bean/BeanTest.java
+++ 
b/integration-tests/bean/src/test/java/org/apache/camel/quarkus/component/bean/BeanTest.java
@@ -20,7 +20,6 @@ import io.quarkus.test.junit.QuarkusTest;
 import io.restassured.RestAssured;
 import io.restassured.http.ContentType;
 import org.apache.camel.quarkus.component.bean.model.Employee;
-import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
 
 import static org.hamcrest.Matchers.equalTo;
@@ -144,17 +143,6 @@ public class BeanTest {
                 .body(equalTo("wlpb-hello(wlpb-route-31wp,cflap-bean-31wp)"));
     }
 
-    @Disabled("https://github.com/apache/camel-quarkus/issues/2580";)
-    @Test
-    public void consumeAnnotation() {
-        RestAssured.given()
-                .contentType(ContentType.TEXT)
-                .body("foo")
-                .post("/bean/route/consumeAnnotation")
-                .then()
-                .body(equalTo("Consumed foo"));
-    }
-
     @Test
     public void methodWithExchangeArg() {
         RestAssured.given()
diff --git 
a/integration-tests/bean/src/main/java/org/apache/camel/quarkus/component/bean/ConsumeAnnotationBean.java
 
b/integration-tests/bean/src/test/java/org/apache/camel/quarkus/component/bean/ConsumeAnnotationIT.java
similarity index 77%
rename from 
integration-tests/bean/src/main/java/org/apache/camel/quarkus/component/bean/ConsumeAnnotationBean.java
rename to 
integration-tests/bean/src/test/java/org/apache/camel/quarkus/component/bean/ConsumeAnnotationIT.java
index 2119785..6c6377f 100644
--- 
a/integration-tests/bean/src/main/java/org/apache/camel/quarkus/component/bean/ConsumeAnnotationBean.java
+++ 
b/integration-tests/bean/src/test/java/org/apache/camel/quarkus/component/bean/ConsumeAnnotationIT.java
@@ -16,16 +16,8 @@
  */
 package org.apache.camel.quarkus.component.bean;
 
-import org.apache.camel.Consume;
-
-/**
- * A bean annotated with {@code @Consume}
- */
-public class ConsumeAnnotationBean {
-
-    @Consume("direct:consumeAnnotation")
-    public String consumeAnnotation(String name) {
-        return "Consumed " + name;
-    }
+import io.quarkus.test.junit.NativeImageTest;
 
+@NativeImageTest
+public class ConsumeAnnotationIT extends ConsumeAnnotationTest {
 }
diff --git 
a/integration-tests/bean/src/test/java/org/apache/camel/quarkus/component/bean/ConsumeAnnotationTest.java
 
b/integration-tests/bean/src/test/java/org/apache/camel/quarkus/component/bean/ConsumeAnnotationTest.java
new file mode 100644
index 0000000..6dd15cf
--- /dev/null
+++ 
b/integration-tests/bean/src/test/java/org/apache/camel/quarkus/component/bean/ConsumeAnnotationTest.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.apache.camel.quarkus.component.bean;
+
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import io.restassured.http.ContentType;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.Matchers.equalTo;
+
+@QuarkusTest
+public class ConsumeAnnotationTest {
+    @Test
+    public void consumeAnnotation() {
+        RestAssured.given()
+                .contentType(ContentType.TEXT)
+                .body("foo")
+                .post("/bean/route/consumeAnnotation")
+                .then()
+                .body(equalTo("Consumed foo"));
+    }
+
+    @Test
+    public void defaultNamedConsumeAnnotation() {
+        RestAssured.given()
+                .contentType(ContentType.TEXT)
+                .body("bar")
+                .post("/bean/route/defaultNamedConsumeAnnotation")
+                .then()
+                .body(equalTo("Consumed named bar"));
+    }
+
+    @Test
+    public void customNamedConsumeAnnotation() {
+        RestAssured.given()
+                .contentType(ContentType.TEXT)
+                .body("baz")
+                .post("/bean/route/customNamedConsumeAnnotation")
+                .then()
+                .body(equalTo("Consumed custom named baz"));
+    }
+
+    @Test
+    public void singletonConsumeAnnotation() {
+        RestAssured.given()
+                .contentType(ContentType.TEXT)
+                .body("goo")
+                .post("/bean/route/singletonConsumeAnnotation")
+                .then()
+                .body(equalTo("Consumed singleton goo"));
+    }
+}

Reply via email to