You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2016/01/15 14:44:09 UTC

[1/9] camel git commit: CAMEL-9201: Improved Camel CDI component

Repository: camel
Updated Branches:
  refs/heads/master d3d75d287 -> 0421c24df


http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/CamelContextC.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/CamelContextC.java b/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/CamelContextC.java
new file mode 100644
index 0000000..d4de27d
--- /dev/null
+++ b/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/CamelContextC.java
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.itest.cdi;
+
+import javax.enterprise.context.ApplicationScoped;
+
+import org.apache.camel.cdi.CdiCamelContext;
+import org.apache.camel.cdi.ContextName;
+
+@ApplicationScoped
+@ContextName("contextC")
+public class CamelContextC extends CdiCamelContext {
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/CamelContextD.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/CamelContextD.java b/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/CamelContextD.java
new file mode 100644
index 0000000..0934241
--- /dev/null
+++ b/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/CamelContextD.java
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.itest.cdi;
+
+import javax.enterprise.context.ApplicationScoped;
+
+import org.apache.camel.cdi.CdiCamelContext;
+import org.apache.camel.cdi.ContextName;
+
+@ApplicationScoped
+@ContextName("contextD")
+public class CamelContextD extends CdiCamelContext {
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextA.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextA.java b/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextA.java
index 4a55f51..a9db087 100644
--- a/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextA.java
+++ b/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextA.java
@@ -28,29 +28,31 @@ import org.apache.camel.component.mock.MockEndpoint;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-/**
- * Uses contextA with explicit context names on all Camel annotations
- */
 @ContextName("contextA")
 public class RoutesContextA extends RouteBuilder {
-    private static final Logger LOG = LoggerFactory.getLogger(RoutesContextA.class);
 
-    @EndpointInject(uri = "mock:A.b", context = "contextA")
-    public MockEndpoint b;
+    private static final Logger LOG = LoggerFactory.getLogger(RoutesContextA.class);
 
-    @Inject @Uri(value = "seda:A.a", context = "contextA")
+    @Inject
+    @ContextName("contextA")
+    @Uri(value = "seda:A.a")
     Endpoint a;
 
-    @Inject @Uri(value = "seda:A.a", context = "contextA")
+    @EndpointInject(uri = "mock:A.b", context = "contextA")
+    MockEndpoint b;
+
+    @Inject
+    @ContextName("contextA")
+    @Uri(value = "seda:A.a")
     ProducerTemplate producer;
 
     @Override
-    public void configure() throws Exception {
+    public void configure() {
         LOG.info("Adding route from " + a + " to " + b);
         from(a).to(b);
     }
 
-    public void sendMessages() {
+    void sendMessages() {
         for (Object expectedBody : Constants.EXPECTED_BODIES_A) {
             LOG.info("Sending " + expectedBody + " to " + producer.getDefaultEndpoint());
             producer.sendBody(expectedBody);

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextB.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextB.java b/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextB.java
index 5679527..89e0933 100644
--- a/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextB.java
+++ b/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextB.java
@@ -28,20 +28,22 @@ import org.apache.camel.component.mock.MockEndpoint;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-/**
- * Uses contextB with explicit context names on all Camel annotations
- */
 @ContextName("contextB")
 public class RoutesContextB extends RouteBuilder {
-    private static final Logger LOG = LoggerFactory.getLogger(RoutesContextB.class);
 
-    @EndpointInject(uri = "mock:B.b", context = "contextB")
-    public MockEndpoint b;
+    private static final Logger LOG = LoggerFactory.getLogger(RoutesContextB.class);
 
-    @Inject @Uri(value = "seda:B.a", context = "contextB")
+    @Inject
+    @ContextName("contextB")
+    @Uri(value = "seda:B.a")
     Endpoint a;
 
-    @Inject @Uri(value = "seda:B.a", context = "contextB")
+    @EndpointInject(uri = "mock:B.b", context = "contextB")
+    MockEndpoint b;
+
+    @Inject
+    @ContextName("contextB")
+    @Uri(value = "seda:B.a")
     ProducerTemplate producer;
 
     @Override
@@ -50,7 +52,7 @@ public class RoutesContextB extends RouteBuilder {
         from(a).to(b);
     }
 
-    public void sendMessages() {
+    void sendMessages() {
         for (Object expectedBody : Constants.EXPECTED_BODIES_B) {
             LOG.info("Sending " + expectedBody + " to " + producer.getDefaultEndpoint());
             producer.sendBody(expectedBody);

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextC.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextC.java b/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextC.java
index cb9e96d..507a1d4 100644
--- a/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextC.java
+++ b/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextC.java
@@ -28,21 +28,22 @@ import org.apache.camel.component.mock.MockEndpoint;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-/**
- * Uses contextC implicitly using that context for all injection points without
- * having to mention them on each camel annotation
- */
 @ContextName("contextC")
 public class RoutesContextC extends RouteBuilder {
+
     private static final Logger LOG = LoggerFactory.getLogger(RoutesContextC.class);
 
-    @Inject @Uri("seda:C.a")
+    @Inject
+    @ContextName("contextC")
+    @Uri("seda:C.a")
     Endpoint a;
 
-    @EndpointInject(uri = "mock:C.b")
+    @EndpointInject(uri = "mock:C.b", context = "contextC")
     MockEndpoint b;
 
-    @Inject @Uri("seda:C.a")
+    @Inject
+    @ContextName("contextC")
+    @Uri("seda:C.a")
     ProducerTemplate producer;
 
     @Override
@@ -50,7 +51,7 @@ public class RoutesContextC extends RouteBuilder {
         from(a).to(b);
     }
 
-    public void sendMessages() {
+    void sendMessages() {
         for (Object expectedBody : Constants.EXPECTED_BODIES_C) {
             LOG.info("Sending " + expectedBody + " to " + producer.getDefaultEndpoint());
             producer.sendBody(expectedBody);

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextD.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextD.java b/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextD.java
index a36b8a8..2b7f172 100644
--- a/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextD.java
+++ b/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/RoutesContextD.java
@@ -28,29 +28,30 @@ import org.apache.camel.component.mock.MockEndpoint;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-/**
- * Uses contextD implicitly using that context for all injection points without
- * having to mention them on each camel annotation
- */
 @ContextName("contextD")
 public class RoutesContextD extends RouteBuilder {
+
     private static final Logger LOG = LoggerFactory.getLogger(RoutesContextD.class);
 
-    @Inject @Uri("seda:D.a")
+    @Inject
+    @ContextName("contextD")
+    @Uri("seda:D.a")
     Endpoint a;
 
-    @EndpointInject(uri = "mock:D.b")
+    @EndpointInject(uri = "mock:D.b", context = "contextD")
     MockEndpoint b;
 
-    @Inject @Uri("seda:D.a")
+    @Inject
+    @ContextName("contextD")
+    @Uri("seda:D.a")
     ProducerTemplate producer;
 
     @Override
-    public void configure() throws Exception {
+    public void configure() {
         from(a).to(b);
     }
 
-    public void sendMessages() {
+    void sendMessages() {
         for (Object expectedBody : Constants.EXPECTED_BODIES_D) {
             LOG.info("Sending " + expectedBody + " to " + producer.getDefaultEndpoint());
             producer.sendBody(expectedBody);

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/properties/Camel1Config.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/properties/Camel1Config.java b/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/properties/Camel1Config.java
deleted file mode 100644
index dcc1a03..0000000
--- a/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/properties/Camel1Config.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.itest.cdi.properties;
-
-import org.apache.deltaspike.core.api.config.PropertyFileConfig;
-
-/**
- * Registers new properties configuration.
- */
-public class Camel1Config implements PropertyFileConfig {
-
-    private static final long serialVersionUID = 1L;
-
-    @Override
-    public String getPropertyFileName() {
-        return "camel1.properties";
-    }
-
-    @Override
-    public boolean isOptional() {
-        return false;
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/properties/Camel2Config.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/properties/Camel2Config.java b/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/properties/Camel2Config.java
deleted file mode 100644
index db03ff6..0000000
--- a/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/properties/Camel2Config.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.itest.cdi.properties;
-
-import org.apache.deltaspike.core.api.config.PropertyFileConfig;
-
-/**
- * Registers new properties configuration.
- */
-public class Camel2Config implements PropertyFileConfig {
-
-    private static final long serialVersionUID = 1L;
-
-    @Override
-    public String getPropertyFileName() {
-        return "camel2.properties";
-    };
-
-    @Override
-    public boolean isOptional() {
-        return false;
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/tests/camel-itest-cdi/src/test/java/org/apache/camel/itest/cdi/CamelCdiTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-cdi/src/test/java/org/apache/camel/itest/cdi/CamelCdiTest.java b/tests/camel-itest-cdi/src/test/java/org/apache/camel/itest/cdi/CamelCdiTest.java
index ce4ab38..23261ad 100644
--- a/tests/camel-itest-cdi/src/test/java/org/apache/camel/itest/cdi/CamelCdiTest.java
+++ b/tests/camel-itest-cdi/src/test/java/org/apache/camel/itest/cdi/CamelCdiTest.java
@@ -17,20 +17,18 @@
 package org.apache.camel.itest.cdi;
 
 import java.util.Map;
-import java.util.Set;
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.Instance;
 import javax.inject.Inject;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
 import org.apache.camel.ProducerTemplate;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.ContextName;
 import org.apache.camel.cdi.Uri;
-import org.apache.camel.cdi.internal.CamelContextMap;
-import org.apache.camel.cdi.internal.CamelExtension;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.util.CamelContextHelper;
-import org.apache.deltaspike.core.impl.scope.conversation.ConversationBeanHolder;
-import org.apache.deltaspike.core.impl.scope.viewaccess.ViewAccessBeanHolder;
-import org.apache.deltaspike.core.impl.scope.window.WindowBeanHolder;
 import org.jboss.arquillian.container.test.api.Deployment;
 import org.jboss.arquillian.junit.Arquillian;
 import org.jboss.shrinkwrap.api.ShrinkWrap;
@@ -46,27 +44,49 @@ import static org.junit.Assert.assertTrue;
 
 @RunWith(Arquillian.class)
 public class CamelCdiTest {
+
     private static final Logger LOG = LoggerFactory.getLogger(CamelCdiTest.class);
 
+    @Any
     @Inject
-    CamelContextMap camelContextMap;
+    Instance<CamelContext> camelContexts;
+    
     @Inject
+    @ContextName("contextA")
     RoutesContextA routesA;
     @Inject
+    @ContextName("contextB")
     RoutesContextB routesB;
     @Inject
+    @ContextName("contextC")
     RoutesContextC routesC;
     @Inject
+    @ContextName("contextD")
     RoutesContextD routesD;
-
-    @Inject @Uri(value = "seda:foo", context = "contextD")
+    
+    @Inject
+    @ContextName("contextD")
+    @Uri(value = "seda:foo")
     ProducerTemplate producerD;
 
+    @Deployment
+    public static JavaArchive createDeployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            .addPackage(CdiCamelExtension.class.getPackage())
+            .addClasses(CamelContextA.class, RoutesContextA.class,
+                        CamelContextB.class, RoutesContextB.class,
+                        CamelContextC.class, RoutesContextC.class,
+                        CamelContextD.class, RoutesContextD.class)
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
     @Test
     public void checkContextsHaveCorrectEndpointsAndRoutes() throws Exception {
-        Set<Map.Entry<String, CamelContext>> entries = camelContextMap.getCamelContextMap().entrySet();
-        for (Map.Entry<String, CamelContext> entry : entries) {
-            LOG.info("CamelContext " + entry.getKey() + " has endpoints: " + entry.getValue().getEndpointMap().keySet());
+        assertNotNull("camelContexts not injected!", camelContexts);
+
+        for (CamelContext camelContext : camelContexts) {
+            LOG.info("CamelContext " + camelContext + " has endpoints: " + camelContext.getEndpointMap().keySet());
+            camelContext.start();
         }
 
         CamelContext contextA = assertCamelContext("contextA");
@@ -85,7 +105,6 @@ public class CamelCdiTest {
         routesB.sendMessages();
         mockEndpointB.assertIsSatisfied();
 
-        // lets check the routes where we default the context from the @ContextName
         CamelContext contextC = assertCamelContext("contextC");
         assertHasEndpoints(contextC, "seda://C.a", "mock://C.b");
 
@@ -122,21 +141,8 @@ public class CamelCdiTest {
     }
 
     protected CamelContext assertCamelContext(String contextName) {
-        assertNotNull("camelContextMap not injected!", camelContextMap);
-        CamelContext answer = camelContextMap.getMandatoryCamelContext(contextName);
+        CamelContext answer = camelContexts.select(new ContextName.Literal(contextName)).get();
         assertTrue("CamelContext '" + contextName + "' is not started", answer.getStatus().isStarted());
         return answer;
     }
-
-    @Deployment
-    public static JavaArchive createDeployment() {
-        return ShrinkWrap.create(JavaArchive.class)
-                .addPackage(CamelExtension.class.getPackage())
-                .addPackage(RoutesContextA.class.getPackage())
-                // add a bunch of deltaspike packages so we can find those cdi beans to make arquillian happy
-                .addPackage(WindowBeanHolder.class.getPackage())
-                .addPackage(ConversationBeanHolder.class.getPackage())
-                .addPackage(ViewAccessBeanHolder.class.getPackage())
-                .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
-    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/tests/camel-itest-cdi/src/test/java/org/apache/camel/itest/cdi/PropertiesConfigurationTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-cdi/src/test/java/org/apache/camel/itest/cdi/PropertiesConfigurationTest.java b/tests/camel-itest-cdi/src/test/java/org/apache/camel/itest/cdi/PropertiesConfigurationTest.java
new file mode 100644
index 0000000..2ac0b4d
--- /dev/null
+++ b/tests/camel-itest-cdi/src/test/java/org/apache/camel/itest/cdi/PropertiesConfigurationTest.java
@@ -0,0 +1,75 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.itest.cdi;
+
+import java.util.Properties;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.component.properties.PropertiesComponent;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * Verify {@link CdiCamelExtension} with custom properties.
+ */
+@RunWith(Arquillian.class)
+public class PropertiesConfigurationTest {
+
+    @Inject
+    private CamelContext camelContext;
+
+    @Produces
+    @ApplicationScoped
+    @Named("properties")
+    private static PropertiesComponent propertiesComponent() {
+        Properties configuration = new Properties();
+        configuration.put("property", "value");
+        PropertiesComponent component = new PropertiesComponent();
+        component.setInitialProperties(configuration);
+        component.setLocation("classpath:camel1.properties,classpath:camel2.properties");
+        return component;
+    }
+
+    @Deployment
+    public static JavaArchive createDeployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            .addPackage(CdiCamelExtension.class.getPackage())
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    public void checkContext() throws Exception {
+        assertNotNull(camelContext);
+
+        assertEquals("value1", camelContext.resolvePropertyPlaceholders("{{property1}}"));
+        assertEquals("value2", camelContext.resolvePropertyPlaceholders("{{property2}}"));
+        assertEquals("value1_value2", camelContext.resolvePropertyPlaceholders("{{property1}}_{{property2}}"));
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/tests/camel-itest-cdi/src/test/java/org/apache/camel/itest/cdi/properties/PropertiesConfigurationTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-cdi/src/test/java/org/apache/camel/itest/cdi/properties/PropertiesConfigurationTest.java b/tests/camel-itest-cdi/src/test/java/org/apache/camel/itest/cdi/properties/PropertiesConfigurationTest.java
deleted file mode 100644
index c463cd9..0000000
--- a/tests/camel-itest-cdi/src/test/java/org/apache/camel/itest/cdi/properties/PropertiesConfigurationTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.itest.cdi.properties;
-
-import javax.inject.Inject;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.cdi.component.properties.CdiPropertiesComponent;
-import org.apache.camel.cdi.internal.CamelExtension;
-import org.apache.deltaspike.core.impl.scope.conversation.ConversationBeanHolder;
-import org.apache.deltaspike.core.impl.scope.viewaccess.ViewAccessBeanHolder;
-import org.apache.deltaspike.core.impl.scope.window.WindowBeanHolder;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.asset.EmptyAsset;
-import org.jboss.shrinkwrap.api.spec.JavaArchive;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-/**
- * Verify if {@link CamelExtension} with custom properties.
- */
-@RunWith(Arquillian.class)
-public class PropertiesConfigurationTest {
-
-    @Inject
-    private CamelContext camelContext;
-
-    @Test
-    public void checkContext() throws Exception {
-        assertNotNull(camelContext);
-
-        assertEquals("value1", camelContext.resolvePropertyPlaceholders("{{property1}}"));
-        assertEquals("value2", camelContext.resolvePropertyPlaceholders("{{property2}}"));
-        assertEquals("value1_value2", camelContext.resolvePropertyPlaceholders("{{property1}}_{{property2}}"));
-    }
-
-    @Deployment
-    public static JavaArchive createDeployment() {
-        return ShrinkWrap.create(JavaArchive.class)
-            .addPackage(CamelExtension.class.getPackage())
-            .addPackage(CdiPropertiesComponent.class.getPackage())
-            .addClass(Camel1Config.class)
-            .addClass(Camel2Config.class)
-            // add a bunch of deltaspike packages so we can find those cdi beans to make arquillian happy
-            .addPackage(WindowBeanHolder.class.getPackage())
-            .addPackage(ConversationBeanHolder.class.getPackage())
-            .addPackage(ViewAccessBeanHolder.class.getPackage())
-            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/tooling/archetypes/camel-archetype-cdi/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-cdi/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml b/tooling/archetypes/camel-archetype-cdi/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml
index b797ba7..970a5b6 100644
--- a/tooling/archetypes/camel-archetype-cdi/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml
+++ b/tooling/archetypes/camel-archetype-cdi/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml
@@ -25,7 +25,7 @@
       <defaultValue>${project.version}</defaultValue>
     </requiredProperty>
     <requiredProperty key="cdi-api-version">
-      <defaultValue>1.2</defaultValue>
+      <defaultValue>${cdi-api-1.2-version}</defaultValue>
     </requiredProperty>
     <requiredProperty key="deltaspike-version">
       <defaultValue>${deltaspike-version}</defaultValue>
@@ -77,7 +77,7 @@
     <fileSet filtered="true" encoding="UTF-8">
       <directory></directory>
       <includes>
-        <include>ReadMe.txt</include>
+        <include>ReadMe.md</include>
       </includes>
     </fileSet>
   </fileSets>

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/tooling/archetypes/camel-archetype-cdi/src/main/resources/archetype-resources/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-cdi/src/main/resources/archetype-resources/pom.xml b/tooling/archetypes/camel-archetype-cdi/src/main/resources/archetype-resources/pom.xml
index 3bd0efe..e08fb5f 100644
--- a/tooling/archetypes/camel-archetype-cdi/src/main/resources/archetype-resources/pom.xml
+++ b/tooling/archetypes/camel-archetype-cdi/src/main/resources/archetype-resources/pom.xml
@@ -41,7 +41,7 @@
       <version>${camel-version}</version>
     </dependency>
 
-    <!-- cdi api -->
+    <!-- CDI API -->
     <dependency>
       <groupId>javax.enterprise</groupId>
       <artifactId>cdi-api</artifactId>
@@ -62,9 +62,16 @@
       <version>${weld2-version}</version>
     </dependency>
     <dependency>
+      <groupId>org.apache.deltaspike.core</groupId>
+      <artifactId>deltaspike-core-api</artifactId>
+      <version>${deltaspike-version}</version>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
       <groupId>org.apache.deltaspike.cdictrl</groupId>
       <artifactId>deltaspike-cdictrl-weld</artifactId>
       <version>${deltaspike-version}</version>
+      <scope>runtime</scope>
     </dependency>
 
     <!-- logging -->
@@ -72,11 +79,13 @@
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-log4j12</artifactId>
       <version>${slf4j-version}</version>
+      <scope>runtime</scope>
     </dependency>
     <dependency>
       <groupId>log4j</groupId>
       <artifactId>log4j</artifactId>
       <version>${log4j-version}</version>
+      <scope>runtime</scope>
     </dependency>
 
     <!-- testing -->

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/tooling/archetypes/camel-archetype-cdi/src/main/resources/archetype-resources/src/main/java/MyRoutes.java
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-cdi/src/main/resources/archetype-resources/src/main/java/MyRoutes.java b/tooling/archetypes/camel-archetype-cdi/src/main/resources/archetype-resources/src/main/java/MyRoutes.java
index 03c8740..1592037 100644
--- a/tooling/archetypes/camel-archetype-cdi/src/main/resources/archetype-resources/src/main/java/MyRoutes.java
+++ b/tooling/archetypes/camel-archetype-cdi/src/main/resources/archetype-resources/src/main/java/MyRoutes.java
@@ -26,7 +26,6 @@ import org.apache.camel.cdi.Uri;
 /**
  * Configures all our Camel routes, components, endpoints and beans
  */
-@ContextName("myCdiCamelContext")
 public class MyRoutes extends RouteBuilder {
 
     @Inject
@@ -38,7 +37,7 @@ public class MyRoutes extends RouteBuilder {
     private Endpoint resultEndpoint;
 
     @Override
-    public void configure() throws Exception {
+    public void configure() {
         // you can configure the route rule with Java DSL here
 
         from(inputEndpoint)


[8/9] camel git commit: CAMEL-9201: Improved Camel CDI component

Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelContextNameStrategy.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelContextNameStrategy.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelContextNameStrategy.java
new file mode 100644
index 0000000..4b14b9d
--- /dev/null
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelContextNameStrategy.java
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cdi;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.camel.impl.DefaultCamelContextNameStrategy;
+import org.apache.camel.spi.CamelContextNameStrategy;
+
+/**
+ * A {@link CamelContextNameStrategy} for Camel contexts that are managed by Camel CDI.
+ *
+ * As opposed to {@link org.apache.camel.impl.DefaultCamelContextNameStrategy},
+ * this implementation does not increment the suffix for proxies that are created
+ * each time a contextual reference to a normal-scoped bean is retrieved.
+ *
+ * It is used by Camel CDI for custom Camel context beans that do not override
+ * the context name nor the naming strategy.
+ *
+ * @see CamelContextNameStrategy
+ */
+@Vetoed
+final class CdiCamelContextNameStrategy extends DefaultCamelContextNameStrategy implements CamelContextNameStrategy {
+
+    private static final AtomicInteger CONTEXT_COUNTER = new AtomicInteger(0);
+
+    @Override
+    public String getNextName() {
+        return "camel" + "-" + CONTEXT_COUNTER.incrementAndGet();
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelEnvironment.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelEnvironment.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelEnvironment.java
new file mode 100644
index 0000000..b5cbf58
--- /dev/null
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelEnvironment.java
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cdi;
+
+import javax.enterprise.inject.spi.Annotated;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.InjectionTarget;
+import javax.enterprise.inject.spi.Producer;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.core.osgi.utils.BundleContextUtils;
+
+@Vetoed
+final class CdiCamelEnvironment {
+
+    private final boolean hasBundleContext;
+
+    CdiCamelEnvironment() {
+        hasBundleContext = isCamelCoreOsgiPresent() && hasBundleContext(CdiCamelExtension.class);
+    }
+
+    <T extends CamelContext> Producer<T> camelContextProducer(Producer<T> delegate, Annotated annotated, BeanManager manager, CdiCamelExtension extension) {
+        CamelContextProducer<T> producer = new CamelContextProducer<>(delegate, annotated, manager, extension);
+        return hasBundleContext ? new CamelContextOsgiProducer<>(producer) : producer;
+    }
+
+    <T extends CamelContext> InjectionTarget<T> camelContextInjectionTarget(InjectionTarget<T> delegate, Annotated annotated, BeanManager manager, CdiCamelExtension extension) {
+        CamelContextProducer<T> producer = new CamelContextProducer<>(delegate, annotated, manager, extension);
+        return new CamelContextInjectionTarget<>(delegate, hasBundleContext ? new CamelContextOsgiProducer<>(producer) : producer);
+    }
+
+    private static boolean isCamelCoreOsgiPresent() {
+        try {
+            getClassLoader(CdiCamelExtension.class).loadClass("org.apache.camel.core.osgi.OsgiCamelContextHelper");
+            return true;
+        } catch (ClassNotFoundException cause) {
+            return false;
+        }
+    }
+
+    private static boolean hasBundleContext(Class clazz) {
+        return BundleContextUtils.getBundleContext(clazz) != null;
+    }
+
+    private static ClassLoader getClassLoader(Class<?> clazz) {
+        if (Thread.currentThread().getContextClassLoader() != null) {
+            return Thread.currentThread().getContextClassLoader();
+        } else {
+            return clazz.getClassLoader();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelExtension.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelExtension.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelExtension.java
new file mode 100755
index 0000000..6951cc3
--- /dev/null
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelExtension.java
@@ -0,0 +1,328 @@
+/**
+ * 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.cdi;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.EventObject;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import static java.util.Collections.newSetFromMap;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.Default;
+import javax.enterprise.inject.InjectionException;
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.spi.AfterBeanDiscovery;
+import javax.enterprise.inject.spi.AfterDeploymentValidation;
+import javax.enterprise.inject.spi.Annotated;
+import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.ObserverMethod;
+import javax.enterprise.inject.spi.ProcessAnnotatedType;
+import javax.enterprise.inject.spi.ProcessBean;
+import javax.enterprise.inject.spi.ProcessInjectionTarget;
+import javax.enterprise.inject.spi.ProcessObserverMethod;
+import javax.enterprise.inject.spi.ProcessProducer;
+import javax.enterprise.inject.spi.ProcessProducerField;
+import javax.enterprise.inject.spi.ProcessProducerMethod;
+import javax.inject.Named;
+
+import org.apache.camel.BeanInject;
+import org.apache.camel.CamelContext;
+import org.apache.camel.CamelContextAware;
+import org.apache.camel.Consume;
+import org.apache.camel.Converter;
+import org.apache.camel.Endpoint;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.PropertyInject;
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.ServiceStatus;
+import org.apache.camel.management.event.AbstractExchangeEvent;
+import org.apache.camel.model.RouteContainer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.apache.camel.cdi.CdiSpiHelper.hasAnnotation;
+
+public class CdiCamelExtension implements Extension {
+
+    private final Logger logger = LoggerFactory.getLogger(CdiCamelExtension.class);
+
+    private final CdiCamelEnvironment environment = new CdiCamelEnvironment();
+
+    private final Set<Class<?>> converters = newSetFromMap(new ConcurrentHashMap<Class<?>, Boolean>());
+
+    private final Set<AnnotatedType<?>> camelBeans = newSetFromMap(new ConcurrentHashMap<AnnotatedType<?>, Boolean>());
+
+    private final Set<AnnotatedType<?>> eagerBeans = newSetFromMap(new ConcurrentHashMap<AnnotatedType<?>, Boolean>());
+
+    private final Map<InjectionPoint, ForwardingObserverMethod<?>> cdiEventEndpoints = new ConcurrentHashMap<>();
+
+    private final Map<Annotated, Bean<?>> contextBeans = new ConcurrentHashMap<>();
+
+    private final Set<Annotation> contextQualifiers = newSetFromMap(new ConcurrentHashMap<Annotation, Boolean>());
+
+    private final Set<Annotation> eventQualifiers = newSetFromMap(new ConcurrentHashMap<Annotation, Boolean>());
+
+    private final Map<Method, Bean<?>> producerBeans = new ConcurrentHashMap<>();
+
+    private final Map<Method, Set<Annotation>> producerQualifiers = new ConcurrentHashMap<>();
+
+    ForwardingObserverMethod<?> getObserverMethod(InjectionPoint ip) {
+        return cdiEventEndpoints.get(ip);
+    }
+
+    Set<Annotation> getObserverEvents() {
+        return eventQualifiers;
+    }
+
+    Bean<?> getContextBean(Annotated annotated) {
+        return contextBeans.get(annotated);
+    }
+
+    Set<Annotation> getContextQualifiers() {
+        return contextQualifiers;
+    }
+
+    private void processAnnotatedType(@Observes ProcessAnnotatedType<?> pat) {
+        if (pat.getAnnotatedType().isAnnotationPresent(Vetoed.class)) {
+            pat.veto();
+        }
+        if (hasAnnotation(pat.getAnnotatedType(), Converter.class)) {
+            converters.add(pat.getAnnotatedType().getJavaClass());
+        }
+        if (hasAnnotation(pat.getAnnotatedType(), BeanInject.class, Consume.class, EndpointInject.class, Produce.class, PropertyInject.class)) {
+            camelBeans.add(pat.getAnnotatedType());
+        }
+        if (hasAnnotation(pat.getAnnotatedType(), Consume.class)) {
+            eagerBeans.add(pat.getAnnotatedType());
+        }
+    }
+
+    private void camelContextAware(@Observes ProcessAnnotatedType<? extends CamelContextAware> pat) {
+        camelBeans.add(pat.getAnnotatedType());
+    }
+
+    private <T extends CamelContext> void camelContextBeans(@Observes ProcessInjectionTarget<T> pit, BeanManager manager) {
+        pit.setInjectionTarget(environment.camelContextInjectionTarget(pit.getInjectionTarget(), pit.getAnnotatedType(), manager, this));
+    }
+
+    private <T extends CamelContext> void camelContextProducers(@Observes ProcessProducer<?, T> pp, BeanManager manager) {
+        pp.setProducer(environment.camelContextProducer(pp.getProducer(), pp.getAnnotatedMember(), manager, this));
+    }
+
+    private <T> void camelBeansPostProcessor(@Observes ProcessInjectionTarget<T> pit, BeanManager manager) {
+        if (camelBeans.contains(pit.getAnnotatedType())) {
+            pit.setInjectionTarget(new CamelBeanInjectionTarget<>(pit.getInjectionTarget(), manager));
+        }
+    }
+
+    private void cdiEventEndpoints(@Observes ProcessBean<?> pb) {
+        for (InjectionPoint ip : pb.getBean().getInjectionPoints()) {
+            if (!CdiEventEndpoint.class.equals(CdiSpiHelper.getRawType(ip.getType()))) {
+                continue;
+            }
+            // TODO: refine the key to the type and qualifiers instead of the whole injection point as it leads to registering redundant observers
+            if (ip.getType() instanceof ParameterizedType) {
+                cdiEventEndpoints.put(ip, new ForwardingObserverMethod<>(((ParameterizedType) ip.getType()).getActualTypeArguments()[0], ip.getQualifiers()));
+            } else if (ip.getType() instanceof Class) {
+                cdiEventEndpoints.put(ip, new ForwardingObserverMethod<>(Object.class, ip.getQualifiers()));
+            }
+        }
+    }
+
+    private <T extends Endpoint> void endpointBeans(@Observes ProcessProducerMethod<T, CdiCamelFactory> ppm) {
+        producerBeans.put(ppm.getAnnotatedProducerMethod().getJavaMember(), ppm.getBean());
+    }
+
+    private void producerTemplateBeans(@Observes ProcessProducerMethod<ProducerTemplate, CdiCamelFactory> ppm) {
+        producerBeans.put(ppm.getAnnotatedProducerMethod().getJavaMember(), ppm.getBean());
+    }
+
+    private void camelFactoryProducers(@Observes ProcessAnnotatedType<CdiCamelFactory> pat, BeanManager manager) {
+        AnnotatedType<CdiCamelFactory> at = pat.getAnnotatedType();
+        Set<AnnotatedMethod<? super CdiCamelFactory>> methods = new HashSet<>();
+        for (AnnotatedMethod<? super CdiCamelFactory> am : pat.getAnnotatedType().getMethods()) {
+            if (!am.isAnnotationPresent(Produces.class)) {
+                continue;
+            }
+            Class<?> type = CdiSpiHelper.getRawType(am.getBaseType());
+            if (Endpoint.class.isAssignableFrom(type) || ProducerTemplate.class.equals(type)) {
+                Set<Annotation> qualifiers = CdiSpiHelper.getQualifiers(am, manager);
+                producerQualifiers.put(am.getJavaMember(), qualifiers.isEmpty() ? Collections.<Annotation>singleton(DefaultLiteral.INSTANCE) : qualifiers);
+                Set<Annotation> annotations = new HashSet<>(am.getAnnotations());
+                annotations.removeAll(qualifiers);
+                annotations.add(Excluded.INSTANCE);
+                methods.add(new AnnotatedMethodDelegate<>(am, annotations));
+            }
+        }
+        pat.setAnnotatedType(new AnnotatedTypeDelegate<>(at, methods));
+    }
+
+    private <T extends EventObject> void camelEventNotifiers(@Observes ProcessObserverMethod<T, ?> pom) {
+        // Only activate Camel event notifiers for explicit Camel event observers, that is, an observer method for a super type won't activate notifiers.
+        Type type = pom.getObserverMethod().getObservedType();
+        // Camel events are raw types
+        if (type instanceof Class && Class.class.cast(type).getPackage().equals(AbstractExchangeEvent.class.getPackage())) {
+            eventQualifiers.addAll(pom.getObserverMethod().getObservedQualifiers().isEmpty() ? Collections.singleton(AnyLiteral.INSTANCE) : pom.getObserverMethod().getObservedQualifiers());
+        }
+    }
+
+    private <T extends CamelContext> void camelContextBeans(@Observes ProcessBean<T> pb) {
+        processCamelContextBean(pb.getAnnotated(), pb.getBean());
+    }
+
+    private <T extends CamelContext> void camelContextProducerFields(@Observes ProcessProducerField<T, ?> pb) {
+        processCamelContextBean(pb.getAnnotated(), pb.getBean());
+    }
+
+    private <T extends CamelContext> void camelContextProducerMethods(@Observes ProcessProducerMethod<T, ?> pb) {
+        processCamelContextBean(pb.getAnnotated(), pb.getBean());
+    }
+
+    private void processCamelContextBean(Annotated annotated, Bean<?> bean) {
+        contextQualifiers.addAll(bean.getQualifiers());
+        // Annotated must be wrapped because of OWB-1099
+        contextBeans.put(new AnnotatedWrapper(annotated), bean);
+    }
+
+    private void cdiCamelFactoryProducers(@Observes AfterBeanDiscovery abd) {
+        for (Map.Entry<Method, Bean<?>> producer : producerBeans.entrySet()) {
+            Bean<?> bean = producer.getValue();
+            Set<Annotation> qualifiers = new HashSet<>(producerQualifiers.get(producer.getKey()));
+            Class<?> type = producer.getKey().getReturnType();
+            if (CdiEventEndpoint.class.equals(type)) {
+                for (InjectionPoint ip : cdiEventEndpoints.keySet()) {
+                    qualifiers.addAll(ip.getQualifiers());
+                }
+            } else {
+                if (Endpoint.class.isAssignableFrom(type) || ProducerTemplate.class.isAssignableFrom(type)) {
+                    qualifiers.addAll(CdiSpiHelper.excludeElementOfTypes(contextQualifiers, Any.class, Default.class, Named.class));
+                }
+            }
+            // TODO: would be more correct to add a bean for each Camel context bean
+            abd.addBean(new BeanDelegate<>(bean, qualifiers));
+        }
+    }
+
+    private void addDefaultCamelContext(@Observes AfterBeanDiscovery abd, BeanManager manager) {
+        if (contextBeans.isEmpty()) {
+            abd.addBean(new CdiCamelContextBean(manager, environment.camelContextInjectionTarget(new CamelContextDefaultProducer(), null, manager, CdiCamelExtension.this)));
+        }
+    }
+
+    private void addCdiEventObserverMethods(@Observes AfterBeanDiscovery abd) {
+        for (ObserverMethod method : cdiEventEndpoints.values()) {
+            abd.addObserverMethod(method);
+        }
+    }
+
+    private void createCamelContexts(@Observes AfterDeploymentValidation adv, BeanManager manager) {
+        Collection<CamelContext> contexts = new ArrayList<>();
+        for (Bean<?> context : manager.getBeans(CamelContext.class, AnyLiteral.INSTANCE)) {
+            contexts.add(BeanManagerHelper.getReference(manager, CamelContext.class, context));
+        }
+
+        // Add type converters to Camel contexts
+        CdiTypeConverterLoader loader = new CdiTypeConverterLoader();
+        for (Class<?> converter : converters) {
+            for (CamelContext context : contexts) {
+                loader.loadConverterMethods(context.getTypeConverterRegistry(), converter);
+            }
+        }
+
+        // Add routes to Camel contexts
+        boolean deploymentException = false;
+        Set<Bean<?>> routes = new HashSet<>(manager.getBeans(RoutesBuilder.class, AnyLiteral.INSTANCE));
+        routes.addAll(manager.getBeans(RouteContainer.class, AnyLiteral.INSTANCE));
+        for (Bean<?> context : manager.getBeans(CamelContext.class, AnyLiteral.INSTANCE)) {
+            for (Bean<?> route : routes) {
+                Set<Annotation> qualifiers = new HashSet<>(context.getQualifiers());
+                qualifiers.retainAll(route.getQualifiers());
+                if (qualifiers.size() > 1) {
+                    deploymentException |= !addRouteToContext(route, context, manager, adv);
+                }
+            }
+        }
+        // Let's return to avoid starting misconfigured contexts
+        if (deploymentException) {
+            return;
+        }
+
+        // Trigger eager beans instantiation
+        for (AnnotatedType<?> type : eagerBeans) {
+            // Calling toString is necessary to force the initialization of normal-scoped beans
+            BeanManagerHelper.getReferencesByType(manager, type.getJavaClass(), AnyLiteral.INSTANCE).toString();
+        }
+
+        // Start Camel contexts
+        for (CamelContext context : contexts) {
+            if (ServiceStatus.Started.equals(context.getStatus())) {
+                continue;
+            }
+            logger.info("Camel CDI is starting Camel context [{}]", context.getName());
+            try {
+                context.start();
+            } catch (Exception exception) {
+                adv.addDeploymentProblem(exception);
+            }
+        }
+
+        // Clean-up
+        converters.clear();
+        camelBeans.clear();
+        eagerBeans.clear();
+        producerBeans.clear();
+        producerQualifiers.clear();
+    }
+
+    private boolean addRouteToContext(Bean<?> routeBean, Bean<?> contextBean, BeanManager manager, AfterDeploymentValidation adv) {
+        try {
+            CamelContext context = BeanManagerHelper.getReference(manager, CamelContext.class, contextBean);
+            try {
+                Object route = BeanManagerHelper.getReference(manager, Object.class, routeBean);
+                if (route instanceof RoutesBuilder) {
+                    context.addRoutes((RoutesBuilder) route);
+                } else if (route instanceof RouteContainer) {
+                    context.addRouteDefinitions(((RouteContainer) route).getRoutes());
+                } else {
+                    throw new IllegalArgumentException("Invalid routes type [" + routeBean.getBeanClass().getName() + "], must be either of type RoutesBuilder or RouteContainer!");
+                }
+                return true;
+            } catch (Exception cause) {
+                adv.addDeploymentProblem(new InjectionException("Error adding routes of type [" + routeBean.getBeanClass().getName() + "] to Camel context [" + context.getName() + "]", cause));
+            }
+        } catch (Exception exception) {
+            adv.addDeploymentProblem(exception);
+        }
+        return false;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelFactory.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelFactory.java
new file mode 100755
index 0000000..cdb2336
--- /dev/null
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelFactory.java
@@ -0,0 +1,211 @@
+/**
+ * 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.cdi;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.GenericArrayType;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import javax.enterprise.event.Event;
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.InjectionException;
+import javax.enterprise.inject.Instance;
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.Typed;
+import javax.enterprise.inject.UnsatisfiedResolutionException;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.util.TypeLiteral;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.TypeConverter;
+import org.apache.camel.component.mock.MockEndpoint;
+
+final class CdiCamelFactory {
+
+    @Produces
+    private static TypeConverter typeConverter(InjectionPoint ip, @Any Instance<CamelContext> instance, CdiCamelExtension extension) {
+        return selectContext(ip, instance, extension).getTypeConverter();
+    }
+
+    @Uri("")
+    @Produces
+    // Qualifiers are dynamically added in CdiCamelExtension
+    private static ProducerTemplate producerTemplate(InjectionPoint ip, @Any Instance<CamelContext> instance, CdiCamelExtension extension) {
+        Uri uri = CdiSpiHelper.getQualifierByType(ip, Uri.class);
+        try {
+            CamelContext context = uri.context().isEmpty() ? selectContext(ip, instance, extension) : selectContext(uri.context(), instance);
+            ProducerTemplate producerTemplate = context.createProducerTemplate();
+            // FIXME: avoid NPE caused by missing @Uri qualifier when injection point is @ContextName qualified
+            Endpoint endpoint = context.getEndpoint(uri.value(), Endpoint.class);
+            producerTemplate.setDefaultEndpoint(endpoint);
+            return producerTemplate;
+        } catch (Exception cause) {
+            throw new InjectionException("Error injecting producer template annotated with " + uri + " into " + ip, cause);
+        }
+    }
+
+    @Produces
+    @Typed(MockEndpoint.class)
+    // Qualifiers are dynamically added in CdiCamelExtension
+    private static MockEndpoint mockEndpointFromMember(InjectionPoint ip, @Any Instance<CamelContext> instance, CdiCamelExtension extension) {
+        String uri = "mock:" + ip.getMember().getName();
+        try {
+            return selectContext(ip, instance, extension).getEndpoint(uri, MockEndpoint.class);
+        } catch (Exception cause) {
+            throw new InjectionException("Error injecting mock endpoint into " + ip, cause);
+        }
+    }
+
+    @Uri("")
+    @Produces
+    @Typed(MockEndpoint.class)
+    // Qualifiers are dynamically added in CdiCamelExtension
+    private static MockEndpoint mockEndpointFromUri(InjectionPoint ip, @Any Instance<CamelContext> instance, CdiCamelExtension extension) {
+        Uri uri = CdiSpiHelper.getQualifierByType(ip, Uri.class);
+        try {
+            CamelContext context = uri.context().isEmpty() ? selectContext(ip, instance, extension) : selectContext(uri.context(), instance);
+            return context.getEndpoint(uri.value(), MockEndpoint.class);
+        } catch (Exception cause) {
+            throw new InjectionException("Error injecting mock endpoint annotated with " + uri
+                + " into " + ip, cause);
+        }
+    }
+
+    // Maintained for backward compatibility reason though this is redundant with @Uri
+    // see https://issues.apache.org/jira/browse/CAMEL-5553?focusedCommentId=13445936&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13445936
+    @Mock("")
+    @Produces
+    @Typed(MockEndpoint.class)
+    // Qualifiers are dynamically added in CdiCamelExtension
+    private static MockEndpoint createMockEndpoint(InjectionPoint ip, @Any Instance<CamelContext> instance, CdiCamelExtension extension) {
+        Mock mock = CdiSpiHelper.getQualifierByType(ip, Mock.class);
+        try {
+            CamelContext context = mock.context().isEmpty() ? selectContext(ip, instance, extension) : selectContext(mock.context(), instance);
+            return context.getEndpoint(mock.value(), MockEndpoint.class);
+        } catch (Exception cause) {
+            throw new InjectionException("Error injecting mock endpoint annotated with " + mock + " into " + ip, cause);
+        }
+    }
+
+    @Uri("")
+    @Produces
+    // Qualifiers are dynamically added in CdiCamelExtension
+    private static Endpoint endpoint(InjectionPoint ip, @Any Instance<CamelContext> instance, CdiCamelExtension extension) {
+        Uri uri = CdiSpiHelper.getQualifierByType(ip, Uri.class);
+        try {
+            CamelContext context = uri.context().isEmpty() ? selectContext(ip, instance, extension) : selectContext(uri.context(), instance);
+            return context.getEndpoint(uri.value(), Endpoint.class);
+        } catch (Exception cause) {
+            throw new InjectionException("Error injecting endpoint annotated with " + uri + " into " + ip, cause);
+        }
+    }
+
+    @Produces
+    @SuppressWarnings("unchecked")
+    // Qualifiers are dynamically added in CdiCamelExtension
+    private static <T> CdiEventEndpoint<T> cdiEventEndpoint(InjectionPoint ip, @Any Instance<CamelContext> instance, CdiCamelExtension extension, @Any Event<Object> event) throws Exception {
+        CamelContext context = selectContext(ip, instance, extension);
+        Type type = Object.class;
+        if (ip.getType() instanceof ParameterizedType) {
+            type = ((ParameterizedType) ip.getType()).getActualTypeArguments()[0];
+        }
+        String uri = eventEndpointUri(type, ip.getQualifiers());
+        if (context.hasEndpoint(uri) == null) {
+            // FIXME: to be replaced once event firing with dynamic parameterized type is properly supported (see https://issues.jboss.org/browse/CDI-516)
+            TypeLiteral<T> literal = new TypeLiteral<T>() {
+            };
+            for (Field field : TypeLiteral.class.getDeclaredFields()) {
+                if (field.getType().equals(Type.class)) {
+                    field.setAccessible(true);
+                    field.set(literal, type);
+                    break;
+                }
+            }
+            context.addEndpoint(uri,
+                new CdiEventEndpoint<>(
+                    event.select(literal, ip.getQualifiers().toArray(new Annotation[ip.getQualifiers().size()])), uri, context, (ForwardingObserverMethod<T>) extension.getObserverMethod(ip)));
+        }
+        return context.getEndpoint(uri, CdiEventEndpoint.class);
+    }
+
+    private static <T extends CamelContext> T selectContext(String name, Instance<T> instance) {
+        for (T context : instance) {
+            if (name.equals(context.getName())) {
+                return context;
+            }
+        }
+        throw new UnsatisfiedResolutionException("No Camel context with name [" + name + "] is deployed!");
+    }
+
+    private static <T extends CamelContext> T selectContext(InjectionPoint ip, Instance<T> instance, CdiCamelExtension extension) {
+        Collection<Annotation> qualifiers = new HashSet<>(ip.getQualifiers());
+        qualifiers.retainAll(extension.getContextQualifiers());
+        if (qualifiers.isEmpty() && !instance.select(DefaultLiteral.INSTANCE).isUnsatisfied()) {
+            return instance.select(DefaultLiteral.INSTANCE).get();
+        }
+        return instance.select(qualifiers.toArray(new Annotation[qualifiers.size()])).get();
+    }
+
+    private static String eventEndpointUri(Type type, Set<Annotation> qualifiers) {
+        String uri = "cdi-event://" + authorityFromType(type);
+        StringBuilder parameters = new StringBuilder();
+        Iterator<Annotation> it = qualifiers.iterator();
+        while (it.hasNext()) {
+            parameters.append(it.next().annotationType().getCanonicalName());
+            if (it.hasNext()) {
+                parameters.append("%2C");
+            }
+        }
+        if (parameters.length() > 0) {
+            uri += "?qualifiers=" + parameters.toString();
+        }
+        return uri;
+    }
+
+    private static String authorityFromType(Type type) {
+        if (type instanceof Class) {
+            return Class.class.cast(type).getName();
+        }
+        if (type instanceof ParameterizedType) {
+            ParameterizedType pt = (ParameterizedType) type;
+            StringBuilder builder = new StringBuilder(authorityFromType(pt.getRawType()));
+            Iterator<Type> it = Arrays.asList(pt.getActualTypeArguments()).iterator();
+            builder.append("%3C");
+            while (it.hasNext()) {
+                builder.append(authorityFromType(it.next()));
+                if (it.hasNext()) {
+                    builder.append("%2C");
+                }
+            }
+            builder.append("%3E");
+            return builder.toString();
+        }
+        if (type instanceof GenericArrayType) {
+            GenericArrayType arrayType = (GenericArrayType) type;
+            return authorityFromType(arrayType.getGenericComponentType()) + "%5B%5D";
+        }
+        throw new IllegalArgumentException("Cannot create URI authority for event type [" + type + "]");
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelInjector.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelInjector.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelInjector.java
new file mode 100755
index 0000000..471b7f0
--- /dev/null
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelInjector.java
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cdi;
+
+import javax.enterprise.inject.spi.BeanManager;
+
+import org.apache.camel.spi.Injector;
+
+final class CdiCamelInjector implements Injector {
+
+    private final Injector injector;
+
+    private final BeanManager manager;
+
+    CdiCamelInjector(Injector injector, BeanManager manager) {
+        this.injector = injector;
+        this.manager = manager;
+    }
+
+    @Override
+    public <T> T newInstance(Class<T> type) {
+        T instance = BeanManagerHelper.getReferenceByType(manager, type);
+        if (instance != null) {
+            return instance;
+        } else {
+            return injector.newInstance(type);
+        }
+    }
+
+    @Override
+    public <T> T newInstance(Class<T> type, Object instance) {
+        return injector.newInstance(type, instance);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelRegistry.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelRegistry.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelRegistry.java
new file mode 100755
index 0000000..946fecf
--- /dev/null
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelRegistry.java
@@ -0,0 +1,98 @@
+/**
+ * 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.cdi;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+
+import org.apache.camel.component.properties.PropertiesComponent;
+import org.apache.camel.spi.Registry;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The {@link Registry} used by Camel to perform lookup into the CDI {@link BeanManager}.
+ */
+@Vetoed
+final class CdiCamelRegistry implements Registry {
+
+    private final Logger logger = LoggerFactory.getLogger(CdiCamelRegistry.class);
+
+    private final BeanManager manager;
+
+    CdiCamelRegistry(BeanManager manager) {
+        this.manager = manager;
+    }
+
+    @Override
+    public Object lookupByName(String name) {
+        ObjectHelper.notEmpty(name, "name");
+        logger.trace("Looking up bean with name [{}]", name);
+        // Work-around for WELD-2089
+        if ("properties".equals(name) && findByTypeWithName(PropertiesComponent.class).containsKey("properties")) {
+            return BeanManagerHelper.getReferenceByName(manager, name, PropertiesComponent.class);
+        }
+        return BeanManagerHelper.getReferenceByName(manager, name, Object.class);
+    }
+
+    @Override
+    public <T> T lookupByNameAndType(String name, Class<T> type) {
+        ObjectHelper.notEmpty(name, "name");
+        ObjectHelper.notNull(type, "type");
+        logger.trace("Looking up bean with name [{}] of type [{}]", name, type);
+        return BeanManagerHelper.getReferenceByName(manager, name, type);
+    }
+
+    @Override
+    public <T> Map<String, T> findByTypeWithName(Class<T> type) {
+        ObjectHelper.notNull(type, "type");
+        logger.trace("Looking up named beans of type [{}]", type);
+        Map<String, T> references = new HashMap<>();
+        for (Bean<?> bean : manager.getBeans(type, AnyLiteral.INSTANCE)) {
+            if (bean.getName() != null) {
+                references.put(bean.getName(), BeanManagerHelper.getReference(manager, type, bean));
+            }
+        }
+        return references;
+    }
+
+    @Override
+    public <T> Set<T> findByType(Class<T> type) {
+        ObjectHelper.notNull(type, "type");
+        logger.trace("Looking up beans of type [{}]", type);
+        return BeanManagerHelper.getReferencesByType(manager, type, AnyLiteral.INSTANCE);
+    }
+
+    @Override
+    public Object lookup(String name) {
+        return lookupByName(name);
+    }
+
+    @Override
+    public <T> T lookup(String name, Class<T> type) {
+        return lookupByNameAndType(name, type);
+    }
+
+    @Override
+    public <T> Map<String, T> lookupByType(Class<T> type) {
+        return findByTypeWithName(type);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiEventComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiEventComponent.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiEventComponent.java
new file mode 100644
index 0000000..ffc4d89
--- /dev/null
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiEventComponent.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.cdi;
+
+import java.util.Map;
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Named;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.impl.DefaultComponent;
+
+@Named("cdi-event")
+@ApplicationScoped
+/* package-private */ class CdiEventComponent extends DefaultComponent {
+
+    @Override
+    protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) {
+        /* The CDI event endpoint URI follows the format hereafter:
+        
+        cdi-event://PayloadType<T1,...,Tn>[?qualifiers=QualifierType1[,...[,QualifierTypeN]...]]
+
+        with the authority PayloadType (respectively the QualifierType) being the URI escaped fully
+        qualified name of the payload (respectively qualifier) raw type followed by the type parameters
+        section delimited by angle brackets for payload parameterized type.
+
+        Which leads to unfriendly URIs, e.g.:
+
+        cdi-event://org.apache.camel.cdi.se.pojo.EventPayload%3Cjava.lang.Integer%3E?qualifiers=org.apache.camel.cdi.se.qualifier.FooQualifier%2Corg.apache.camel.cdi.se.qualifier.BarQualifier
+
+        From the conceptual standpoint, that shows the high impedance between the typesafe nature of CDI
+        and the dynamic nature of the Camel component model.
+
+        From the implementation standpoint, that would prevent efficient binding between the endpoint
+        instances and observer methods as the CDI container doesn't have any ways of discovering the
+        Camel context model during the deployment phase.
+        */
+        throw new UnsupportedOperationException("Creating CDI event endpoint isn't supported. Use @Inject " + CdiEventEndpoint.class.getSimpleName() + " instead");
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiEventConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiEventConsumer.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiEventConsumer.java
new file mode 100644
index 0000000..f479163
--- /dev/null
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiEventConsumer.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.apache.camel.cdi;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.RuntimeExchangeException;
+import org.apache.camel.impl.DefaultConsumer;
+import org.apache.camel.management.event.AbstractExchangeEvent;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/* package-private */ final class CdiEventConsumer<T> extends DefaultConsumer {
+
+    private final Logger logger = LoggerFactory.getLogger(CdiEventConsumer.class);
+
+    private final CdiEventEndpoint<T> endpoint;
+
+    CdiEventConsumer(CdiEventEndpoint<T> endpoint, Processor processor) {
+        super(endpoint, processor);
+        this.endpoint = endpoint;
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+        endpoint.registerConsumer(this);
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        endpoint.unregisterConsumer(this);
+        super.doStop();
+    }
+
+    void notify(T event) {
+        logger.debug("Consuming CDI event [{}] with {}", event, this);
+
+        Exchange exchange = getEndpoint().createExchange();
+        // TODO: would that be possible to propagate the event metadata?
+        exchange.getIn().setBody(event);
+
+        // Avoid infinite loop of exchange events
+        if (event instanceof AbstractExchangeEvent) {
+            exchange.setProperty(Exchange.NOTIFY_EVENT, Boolean.TRUE);
+        }
+        try {
+            getProcessor().process(exchange);
+        } catch (Exception cause) {
+            throw new RuntimeExchangeException("Error while processing CDI event", exchange, cause);
+        } finally {
+            if (event instanceof AbstractExchangeEvent) {
+                exchange.setProperty(Exchange.NOTIFY_EVENT, Boolean.FALSE);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiEventEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiEventEndpoint.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiEventEndpoint.java
new file mode 100644
index 0000000..a003609
--- /dev/null
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiEventEndpoint.java
@@ -0,0 +1,127 @@
+/**
+ * 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.cdi;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.enterprise.event.Event;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Consumer;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.impl.DefaultEndpoint;
+
+/**
+ * A Camel {@link Endpoint} that bridges the CDI events facility with Camel routes so that CDI events
+ * can be seamlessly observed / consumed (respectively produced / fired) from Camel consumers (respectively by Camel producers).
+ * <p/>
+ * The {@code CdiEventEndpoint<T>} bean can be used to observe / consume CDI events whose event type is {@code T}, for example:
+ * <pre><code>
+ * {@literal @}Inject
+ * CdiEventEndpoint{@literal <}String{@literal >} cdiEventEndpoint;
+ *
+ * from(cdiEventEndpoint).log("CDI event received: ${body}");
+ * </code></pre>
+ *
+ * Conversely, the {@code CdiEventEndpoint<T>} bean can be used to produce / fire CDI events whose event type is {@code T}, for example:
+ * <pre><code>
+ * {@literal @}Inject
+ * CdiEventEndpoint{@literal <}String{@literal >} cdiEventEndpoint;
+ *
+ * from("direct:event").to(cdiEventEndpoint).log("CDI event sent: ${body}");
+ * </code></pre>
+ *
+ * The type variable {@code T}, respectively the qualifiers, of a particular {@code CdiEventEndpoint<T>} injection point
+ * are automatically translated into the parameterized <i>event type</i>, respectively into the <i>event qualifiers</i>, e.g.:
+ * <pre><code>
+ * {@literal @}Inject
+ * {@literal @}FooQualifier
+ * CdiEventEndpoint{@literal <}List{@literal <}String{@literal >}{@literal >} cdiEventEndpoint;
+ *
+ * from("direct:event").to(cdiEventEndpoint);
+ *
+ * void observeCdiEvents({@literal @}Observes {@literal @}FooQualifier List{@literal <}String{@literal >} event) {
+ *     logger.info("CDI event: {}", event);
+ * }
+ * </code></pre>
+ *
+ * When multiple Camel contexts exist in the CDI container, the {@code @ContextName} qualifier can be used
+ * to qualify the {@code CdiEventEndpoint<T>} injection points, e.g.:
+ * <pre><code>
+ * {@literal @}Inject
+ * {@literal @}ContextName("foo")
+ * CdiEventEndpoint{@literal <}List{@literal <}String{@literal >}{@literal >} cdiEventEndpoint;
+ *
+ * // Only observe / consume events having the {@literal @}ContextName("foo") qualifier
+ * from(cdiEventEndpoint).log("Camel context 'foo' > CDI event received: ${body}");
+ *
+ * // Produce / fire events with the {@literal @}ContextName("foo") qualifier
+ * from("...").to(cdiEventEndpoint);
+ *
+ * void observeCdiEvents({@literal @}Observes {@literal @}ContextName("foo") List{@literal <}String{@literal >} event) {
+ *     logger.info("Camel context 'foo' > CDI event: {}", event);
+ * }
+ * </code></pre>
+ */
+public final class CdiEventEndpoint<T> extends DefaultEndpoint {
+
+    private final List<CdiEventConsumer<T>> consumers = new ArrayList<>();
+
+    private final Event<T> event;
+
+    CdiEventEndpoint(Event<T> event, String endpointUri, CamelContext context, ForwardingObserverMethod<T> observer) {
+        super(endpointUri, context);
+        this.event = event;
+        observer.setObserver(this);
+    }
+
+    public Consumer createConsumer(Processor processor) {
+        return new CdiEventConsumer<>(this, processor);
+    }
+
+    @Override
+    public Producer createProducer() {
+        return new CdiEventProducer<>(this, event);
+    }
+
+    @Override
+    public boolean isSingleton() {
+        return true;
+    }
+
+    void registerConsumer(CdiEventConsumer<T> consumer) {
+        synchronized (consumers) {
+            consumers.add(consumer);
+        }
+    }
+
+    void unregisterConsumer(CdiEventConsumer<T> consumer) {
+        synchronized (consumers) {
+            consumers.remove(consumer);
+        }
+    }
+
+    void notify(T t) {
+        synchronized (consumers) {
+            for (CdiEventConsumer<T> consumer : consumers) {
+                consumer.notify(t);
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiEventNotifier.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiEventNotifier.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiEventNotifier.java
new file mode 100644
index 0000000..e9d27e7
--- /dev/null
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiEventNotifier.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.apache.camel.cdi;
+
+import java.lang.annotation.Annotation;
+import java.util.Collection;
+import java.util.EventObject;
+import javax.enterprise.inject.spi.BeanManager;
+
+import org.apache.camel.support.EventNotifierSupport;
+
+final class CdiEventNotifier extends EventNotifierSupport {
+
+    private final BeanManager manager;
+
+    private final Annotation[] qualifiers;
+
+    CdiEventNotifier(BeanManager manager, Collection<Annotation> qualifiers) {
+        this.manager = manager;
+        this.qualifiers = qualifiers.toArray(new Annotation[qualifiers.size()]);
+        // TODO: be more fine grained for the kind of events that are emitted depending on the observed event types
+    }
+
+    @Override
+    public void notify(EventObject event) {
+        manager.fireEvent(event, qualifiers);
+    }
+
+    @Override
+    public boolean isEnabled(EventObject event) {
+        return true;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiEventProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiEventProducer.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiEventProducer.java
new file mode 100644
index 0000000..11cb274
--- /dev/null
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiEventProducer.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.apache.camel.cdi;
+
+import javax.enterprise.event.Event;
+import org.apache.camel.Exchange;
+
+import org.apache.camel.impl.DefaultProducer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/* package-private */ final class CdiEventProducer<T> extends DefaultProducer {
+
+    private final Logger logger = LoggerFactory.getLogger(CdiEventProducer.class);
+
+    private final Event<T> event;
+
+    CdiEventProducer(CdiEventEndpoint<T> endpoint, Event<T> event) {
+        super(endpoint);
+        this.event = event;
+    }
+
+    @Override
+    public void process(Exchange exchange) {
+        logger.debug("Firing CDI event [{}] with {}", event, this);
+        // TODO: leverage Camel type converter mechanism based on the endpoint type
+        // The EventMetadata injection point will be that of the event which is not very useful
+        // for the end user. Using BeanManager.fire would be a way to hide that internal though
+        // it will be necessary to check whether the exchange event type is assignable to the
+        // endpoint event type.
+        event.fire((T) exchange.getIn().getBody());
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiInjector.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiInjector.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiInjector.java
deleted file mode 100644
index afb3a49..0000000
--- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiInjector.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi;
-
-import org.apache.camel.IsSingleton;
-import org.apache.camel.spi.Injector;
-import org.apache.camel.util.ReflectionInjector;
-import org.apache.deltaspike.core.api.provider.BeanProvider;
-
-/**
- * Injector implementation which performs injection with CDI bean provider.
- */
-public class CdiInjector implements Injector {
-
-    /**
-     * Fallback injector used when there is bean of given type registered in CDI.
-     */
-    private Injector injector;
-
-    public CdiInjector() {
-        this(new ReflectionInjector());
-    }
-
-    public CdiInjector(Injector parent) {
-        this.injector = parent;
-    }
-
-    @Override
-    public <T> T newInstance(Class<T> type) {
-        T bean = BeanProvider.getContextualReference(type, true);
-        if (bean != null) {
-            return type.cast(bean);
-        }
-        return injector.newInstance(type);
-    }
-
-    @Override
-    public <T> T newInstance(Class<T> type, Object instance) {
-        if (instance instanceof IsSingleton) {
-            boolean singleton = ((IsSingleton) instance).isSingleton();
-            if (singleton) {
-                return type.cast(instance);
-            }
-        }
-        return newInstance(type);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiSpiHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiSpiHelper.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiSpiHelper.java
new file mode 100644
index 0000000..5bf852e
--- /dev/null
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiSpiHelper.java
@@ -0,0 +1,143 @@
+/**
+ * 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.cdi;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Array;
+import java.lang.reflect.GenericArrayType;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import java.lang.reflect.WildcardType;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+import javax.enterprise.inject.spi.Annotated;
+import javax.enterprise.inject.spi.AnnotatedConstructor;
+import javax.enterprise.inject.spi.AnnotatedField;
+import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.InjectionPoint;
+
+import org.apache.camel.util.ObjectHelper;
+
+@Vetoed
+final class CdiSpiHelper {
+
+    private CdiSpiHelper() {
+    }
+
+    static <T extends Annotation> T getQualifierByType(InjectionPoint ip, Class<T> type) {
+        return getFirstElementOfType(ip.getQualifiers(), type);
+    }
+
+    private static <E, T extends E> T getFirstElementOfType(Collection<E> collection, Class<T> type) {
+        for (E item : collection) {
+            if ((item != null) && type.isAssignableFrom(item.getClass())) {
+                return ObjectHelper.cast(type, item);
+            }
+        }
+        return null;
+    }
+
+    @SafeVarargs
+    static <T> Set<T> excludeElementOfTypes(Set<T> annotations, Class<? extends T>... exclusions) {
+        Set<T> set = new HashSet<>();
+        for (T qualifier : annotations) {
+            boolean exclude = false;
+            for (Class<? extends T> exclusion : exclusions) {
+                if (exclusion.isAssignableFrom(qualifier.getClass())) {
+                    exclude = true;
+                    break;
+                }
+            }
+            if (!exclude) {
+                set.add(qualifier);
+            }
+        }
+        return set;
+    }
+
+    static Class<?> getRawType(Type type) {
+        if (type instanceof Class<?>) {
+            return Class.class.cast(type);
+        } else if (type instanceof ParameterizedType) {
+            return getRawType(ParameterizedType.class.cast(type).getRawType());
+        } else if (type instanceof TypeVariable<?>) {
+            return getBound(TypeVariable.class.cast(type).getBounds());
+        } else if (type instanceof WildcardType) {
+            return getBound(WildcardType.class.cast(type).getUpperBounds());
+        } else if (type instanceof GenericArrayType) {
+            Class<?> rawType = getRawType(GenericArrayType.class.cast(type).getGenericComponentType());
+            if (rawType != null) {
+                return Array.newInstance(rawType, 0).getClass();
+            }
+        }
+        throw new UnsupportedOperationException("Unable to retrieve raw type for [" + type + "]");
+    }
+
+    private static Class<?> getBound(Type[] bounds) {
+        if (bounds.length == 0) {
+            return Object.class;
+        } else {
+            return getRawType(bounds[0]);
+        }
+    }
+
+    @SafeVarargs
+    static boolean hasAnnotation(AnnotatedType<?> type, Class<? extends Annotation>... annotations) {
+        for (Class<? extends Annotation> annotation : annotations) {
+            if (hasAnnotation(type, annotation)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    static boolean hasAnnotation(AnnotatedType<?> type, Class<? extends Annotation> annotation) {
+        if (type.isAnnotationPresent(annotation)) {
+            return true;
+        }
+        for (AnnotatedMethod<?> method : type.getMethods()) {
+            if (method.isAnnotationPresent(annotation)) {
+                return true;
+            }
+        }
+        for (AnnotatedConstructor<?> constructor : type.getConstructors()) {
+            if (constructor.isAnnotationPresent(annotation)) {
+                return true;
+            }
+        }
+        for (AnnotatedField<?> field : type.getFields()) {
+            if (field.isAnnotationPresent(annotation)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    static Set<Annotation> getQualifiers(Annotated annotated, BeanManager manager) {
+        Set<Annotation> qualifiers = new HashSet<>();
+        for (Annotation annotation : annotated.getAnnotations()) {
+            if (manager.isQualifier(annotation.annotationType())) {
+                qualifiers.add(annotation);
+            }
+        }
+        return qualifiers;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiTypeConverterLoader.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiTypeConverterLoader.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiTypeConverterLoader.java
new file mode 100644
index 0000000..b8991e6
--- /dev/null
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiTypeConverterLoader.java
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cdi;
+
+import org.apache.camel.impl.converter.AnnotationTypeConverterLoader;
+import org.apache.camel.spi.TypeConverterRegistry;
+
+@Vetoed
+final class CdiTypeConverterLoader extends AnnotationTypeConverterLoader {
+
+    CdiTypeConverterLoader() {
+        super(null);
+    }
+
+    @Override
+    protected void loadConverterMethods(TypeConverterRegistry registry, Class<?> type) {
+        super.loadConverterMethods(registry, type);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/ContextName.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/ContextName.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/ContextName.java
index f34cb49..2006e71 100644
--- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/ContextName.java
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/ContextName.java
@@ -1,40 +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.apache.camel.cdi;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.builder.RouteBuilder;
-
-/**
- * Used to bind objects to a named {@link CamelContext} instance 
- * such as {@link RouteBuilder} instances.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER})
-public @interface ContextName {
-
-    /**
-     * Returns the name of the CamelContext to add the routes to.
-     * If no value is specified then the default CamelContext is used.
-     */
-    String value() default "";
-}
+/**
+ * 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.cdi;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import javax.enterprise.util.AnnotationLiteral;
+import javax.inject.Qualifier;
+
+/**
+ * CDI qualifier to be used for multi Camel contexts CDI deployment.
+ * {@code CamelContext} beans can be annotated with the {@code @ContextName} qualifier
+ * so that the Camel context is named accordingly, e.g.:
+ *
+ * <pre><code>
+ * {@literal @}ApplicationScoped
+ * {@literal @}ContextName("foo")
+ * public class FooCamelContext extends DefaultCamelContext {
+ * }
+ * </code></pre>
+ *
+ * Camel resources like route builders, endpoints and producer templates can be annotated with
+ * the {@code @ContextName} qualifier as well so that they are associated with the
+ * corresponding Camel context, e.g.:
+ *
+ * <pre><code>
+ * {@literal @}ContextName("foo")
+ * public class FooRouteBuilder extends RouteBuilder {
+ *
+ *     {@literal @}Override
+ *     public void configure() {
+ *         from("direct:bar").to("mock:bar");
+ *     }
+ * }
+ *
+ * {@literal @}Inject
+ * {@literal @}ContextName("foo")
+ * {@literal @}Uri("direct:bar")
+ * ProducerTemplate barProducer;
+ *
+ * {@literal @}Inject
+ * {@literal @}ContextName("foo")
+ * {@literal @}Uri("mock:bar")
+ * MockEndpoint barMockEndpoint;
+ * </code></pre>
+ *
+ * @see org.apache.camel.CamelContext
+ *
+ */
+@Qualifier
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER})
+public @interface ContextName {
+
+    /**
+     * Returns the name of the Camel context.
+     */
+    String value();
+
+    final class Literal extends AnnotationLiteral<ContextName> implements ContextName {
+
+        private static final long serialVersionUID = 1L;
+
+        private final String name;
+
+        public Literal(String name) {
+            this.name = name;
+        }
+
+        @Override
+        public String value() {
+            return name;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/DefaultLiteral.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/DefaultLiteral.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/DefaultLiteral.java
new file mode 100644
index 0000000..c78d6c0
--- /dev/null
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/DefaultLiteral.java
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cdi;
+
+import javax.enterprise.inject.Default;
+import javax.enterprise.util.AnnotationLiteral;
+
+@Vetoed
+final class DefaultLiteral extends AnnotationLiteral<Default> implements Default {
+
+    static final Default INSTANCE = new DefaultLiteral();
+
+    private static final long serialVersionUID = 1L;
+
+    private DefaultLiteral() {
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/DelegateInjectionTarget.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/DelegateInjectionTarget.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/DelegateInjectionTarget.java
new file mode 100644
index 0000000..9fef662
--- /dev/null
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/DelegateInjectionTarget.java
@@ -0,0 +1,51 @@
+/**
+ * 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.cdi;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.InjectionTarget;
+import javax.enterprise.inject.spi.Producer;
+
+abstract class DelegateInjectionTarget<T> extends DelegateProducer<T> implements InjectionTarget<T> {
+
+    private final InjectionTarget<T> delegate;
+
+    DelegateInjectionTarget(InjectionTarget<T> delegate) {
+        super(delegate);
+        this.delegate = delegate;
+    }
+
+    DelegateInjectionTarget(InjectionTarget<T> target, Producer<T> producer) {
+        super(producer);
+        this.delegate = target;
+    }
+
+    @Override
+    public void inject(T instance, CreationalContext<T> ctx) {
+        delegate.inject(instance, ctx);
+    }
+
+    @Override
+    public void postConstruct(T instance) {
+        delegate.postConstruct(instance);
+    }
+
+    @Override
+    public void preDestroy(T instance) {
+        delegate.preDestroy(instance);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/DelegateProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/DelegateProducer.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/DelegateProducer.java
new file mode 100644
index 0000000..05f8516
--- /dev/null
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/DelegateProducer.java
@@ -0,0 +1,51 @@
+/**
+ * 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.cdi;
+
+import java.util.Set;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.Producer;
+
+abstract class DelegateProducer<T> implements Producer<T> {
+
+    private final Producer<T> delegate;
+
+    DelegateProducer(Producer<T> delegate) {
+        this.delegate = delegate;
+    }
+
+    @Override
+    public T produce(CreationalContext<T> ctx) {
+        return delegate.produce(ctx);
+    }
+
+    @Override
+    public void dispose(T instance) {
+        delegate.dispose(instance);
+    }
+
+    @Override
+    public Set<InjectionPoint> getInjectionPoints() {
+        return delegate.getInjectionPoints();
+    }
+
+    @Override
+    public String toString() {
+        return delegate.toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/Excluded.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/Excluded.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/Excluded.java
new file mode 100644
index 0000000..eccf446
--- /dev/null
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/Excluded.java
@@ -0,0 +1,40 @@
+/**
+ * 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.cdi;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import javax.enterprise.util.AnnotationLiteral;
+import javax.inject.Qualifier;
+
+@Qualifier
+@Documented
+@Retention(value = RUNTIME)
+@Target(value = { TYPE, METHOD, PARAMETER, FIELD })
+@interface Excluded {
+
+    Excluded INSTANCE = new ExcludedLiteral();
+
+    final class ExcludedLiteral extends AnnotationLiteral<Excluded>implements Excluded {
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/ForwardingObserverMethod.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/ForwardingObserverMethod.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/ForwardingObserverMethod.java
new file mode 100644
index 0000000..3f2b565
--- /dev/null
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/ForwardingObserverMethod.java
@@ -0,0 +1,78 @@
+/**
+ * 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.cdi;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
+import javax.enterprise.event.Reception;
+import javax.enterprise.event.TransactionPhase;
+import javax.enterprise.inject.spi.ObserverMethod;
+
+import org.apache.camel.CamelContext;
+
+/* package-private */ final class ForwardingObserverMethod<T> implements ObserverMethod<T> {
+
+    // Should be replaced with the Java 8 functional interface Consumer<T>
+    private final AtomicReference<CdiEventEndpoint<T>> observer = new AtomicReference<>();
+
+    private final Type type;
+
+    private final Set<Annotation> qualifiers;
+
+    ForwardingObserverMethod(Type type, Set<Annotation> qualifiers) {
+        this.type = type;
+        this.qualifiers = qualifiers;
+    }
+
+    void setObserver(CdiEventEndpoint<T> observer) {
+        this.observer.set(observer);
+    }
+
+    @Override
+    public Class<?> getBeanClass() {
+        return CamelContext.class;
+    }
+
+    @Override
+    public Type getObservedType() {
+        return type;
+    }
+
+    @Override
+    public Set<Annotation> getObservedQualifiers() {
+        return qualifiers;
+    }
+
+    @Override
+    public Reception getReception() {
+        return Reception.ALWAYS;
+    }
+
+    @Override
+    public TransactionPhase getTransactionPhase() {
+        return TransactionPhase.IN_PROGRESS;
+    }
+
+    @Override
+    public void notify(T event) {
+        if (observer.get() != null) {
+            observer.get().notify(event);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/Main.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/Main.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/Main.java
index 0532870..cd55010 100644
--- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/Main.java
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/Main.java
@@ -17,37 +17,42 @@
 package org.apache.camel.cdi;
 
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
-import javax.xml.bind.JAXBContext;
+import javax.enterprise.inject.UnsatisfiedResolutionException;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.ProducerTemplate;
-import org.apache.camel.impl.DefaultModelJAXBContextFactory;
 import org.apache.camel.main.MainSupport;
-import org.apache.camel.spi.ModelJAXBContextFactory;
-import org.apache.deltaspike.core.api.provider.BeanProvider;
+import org.apache.deltaspike.cdise.api.CdiContainer;
 
 /**
- * Allows Camel and CDI applications to be booted up on the command line as a Java Application
+ * Camel CDI boot integration. Allows Camel and CDI to be booted up on the command line as a JVM process.
+ * See http://camel.apache.org/camel-boot.html.
  */
-public abstract class Main extends MainSupport { // abstract to prevent cdi management
-    private static Main instance;
-    private JAXBContext jaxbContext;
-    private Object cdiContainer; // we don't want to need cdictrl API in OSGi
+@Vetoed
+public class Main extends MainSupport {
 
-    public Main() {
-        // add options...
+    static {
+        // Since version 2.3.0.Final and WELD-1915, Weld SE registers a shutdown hook that conflicts
+        // with Camel main support. See WELD-2051. The system property above is available starting
+        // Weld 2.3.1.Final to deactivate the registration of the shutdown hook.
+        System.setProperty("org.jboss.weld.se.shutdownHook", String.valueOf(Boolean.FALSE));
     }
 
+    private static Main instance;
+
+    private CdiContainer cdiContainer;
+
     public static void main(String... args) throws Exception {
-        Main main = new Main() { };
+        Main main = new Main();
         instance = main;
         main.run(args);
     }
 
     /**
-     * Returns the currently executing main
+     * Returns the currently executing instance.
      *
      * @return the current running instance
      */
@@ -57,46 +62,42 @@ public abstract class Main extends MainSupport { // abstract to prevent cdi mana
 
     @Override
     protected ProducerTemplate findOrCreateCamelTemplate() {
-        ProducerTemplate answer = BeanProvider.getContextualReference(ProducerTemplate.class, true);
-        if (answer != null) {
-            return answer;
+        BeanManager manager = cdiContainer.getBeanManager();
+        Bean<?> bean = manager.resolve(manager.getBeans(CamelContext.class));
+        if (bean == null) {
+            throw new UnsatisfiedResolutionException("No default Camel context is deployed, cannot create default ProducerTemplate!");
         }
-        if (getCamelContexts().isEmpty()) {
-            throw new IllegalArgumentException(
-                    "No CamelContexts are available so cannot create a ProducerTemplate!");
-        }
-        return getCamelContexts().get(0).createProducerTemplate();
+        CamelContext context = (CamelContext) manager.getReference(bean, CamelContext.class, manager.createCreationalContext(bean));
+        return context.createProducerTemplate();
     }
 
     @Override
     protected Map<String, CamelContext> getCamelContextMap() {
-        List<CamelContext> contexts = BeanProvider.getContextualReferences(CamelContext.class, true);
-        Map<String, CamelContext> answer = new HashMap<String, CamelContext>();
-        for (CamelContext context : contexts) {
-            String name = context.getName();
-            answer.put(name, context);
+        BeanManager manager = cdiContainer.getBeanManager();
+        Map<String, CamelContext> answer = new HashMap<>();
+        for (Bean<?> bean : manager.getBeans(CamelContext.class, AnyLiteral.INSTANCE)) {
+            CamelContext context = (CamelContext) manager.getReference(bean, CamelContext.class, manager.createCreationalContext(bean));
+            answer.put(context.getName(), context);
         }
         return answer;
     }
 
-    public ModelJAXBContextFactory getModelJAXBContextFactory() {
-        return new DefaultModelJAXBContextFactory();
-    }
-
     @Override
     protected void doStart() throws Exception {
+        // TODO: Use standard CDI Java SE support when CDI 2.0 becomes a prerequisite
         org.apache.deltaspike.cdise.api.CdiContainer container = org.apache.deltaspike.cdise.api.CdiContainerLoader.getCdiContainer();
         container.boot();
         container.getContextControl().startContexts();
         cdiContainer = container;
         super.doStart();
+        postProcessContext();
     }
 
     @Override
     protected void doStop() throws Exception {
         super.doStop();
         if (cdiContainer != null) {
-            ((org.apache.deltaspike.cdise.api.CdiContainer) cdiContainer).shutdown();
+            cdiContainer.shutdown();
         }
     }
 }


[3/9] camel git commit: CAMEL-9201: Improved Camel CDI component

Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/InjectedTypeConverterTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/InjectedTypeConverterTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/InjectedTypeConverterTest.java
new file mode 100644
index 0000000..6e43984
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/InjectedTypeConverterTest.java
@@ -0,0 +1,103 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cdi.test;
+
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+import javax.inject.Named;
+
+import org.apache.camel.NoTypeConversionAvailableException;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.TypeConverter;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.bean.InjectedTypeConverterRoute;
+import org.apache.camel.cdi.converter.InjectedTypeConverter;
+import org.apache.camel.cdi.pojo.TypeConverterInput;
+import org.apache.camel.cdi.pojo.TypeConverterOutput;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.properties.PropertiesComponent;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Arquillian.class)
+public class InjectedTypeConverterTest {
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test class
+            .addClass(InjectedTypeConverterRoute.class)
+            // Type converter
+            .addClass(InjectedTypeConverter.class)
+            // No need as Camel CDI automatically registers the type converter bean
+            //.addAsManifestResource(new StringAsset("org.apache.camel.cdi.se.converter"), ArchivePaths.create("services/org/apache/camel/TypeConverter"))
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Produces
+    @ApplicationScoped
+    @Named("properties")
+    private static PropertiesComponent configuration() {
+        Properties properties = new Properties();
+        properties.put("property1", "value 1");
+        properties.put("property2", "value 2");
+        PropertiesComponent component = new PropertiesComponent();
+        component.setInitialProperties(properties);
+        return component;
+    }
+
+    @Test
+    public void sendMessageToInbound(@Uri("direct:inbound") ProducerTemplate inbound,
+                                     @Uri("mock:outbound") MockEndpoint outbound) throws InterruptedException {
+        outbound.expectedMessageCount(1);
+
+        TypeConverterInput input = new TypeConverterInput();
+        input.setProperty("property value is [{{property1}}]");
+        
+        inbound.sendBody(input);
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, outbound);
+        assertThat(outbound.getExchanges().get(0).getIn().getBody(TypeConverterOutput.class).getProperty(), is(equalTo("property value is [value 1]")));
+    }
+
+    @Test
+    public void convertWithTypeConverter(TypeConverter converter) throws NoTypeConversionAvailableException {
+        TypeConverterInput input = new TypeConverterInput();
+        input.setProperty("property value is [{{property2}}]");
+
+        TypeConverterOutput output = converter.mandatoryConvertTo(TypeConverterOutput.class, input);
+
+        assertThat(output.getProperty(), is(equalTo("property value is [value 2]")));
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/ManualCamelContextTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/ManualCamelContextTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/ManualCamelContextTest.java
new file mode 100644
index 0000000..31cacd7
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/ManualCamelContextTest.java
@@ -0,0 +1,117 @@
+/**
+ * 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.cdi.test;
+
+import java.util.concurrent.TimeUnit;
+import javax.inject.Inject;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.ServiceStatus;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.bean.ManualCamelRoute;
+import org.apache.camel.cdi.bean.SimpleCamelRoute;
+import org.apache.camel.cdi.qualifier.Manual;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.junit.InSequence;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Arquillian.class)
+public class ManualCamelContextTest {
+
+    @Inject
+    @Uri("direct:start")
+    private ProducerTemplate inbound;
+
+    @Inject
+    @Uri("mock:result")
+    private MockEndpoint outbound;
+
+    @Inject
+    @Uri("direct:manual")
+    private ProducerTemplate manual;
+
+    @Inject
+    @Uri("mock:manual")
+    private MockEndpoint mock;
+
+    @Inject
+    @Manual
+    private ManualCamelRoute builder;
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test classes
+            .addClasses(SimpleCamelRoute.class, ManualCamelRoute.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    @InSequence(1)
+    public void verifyContext(CamelContext context) {
+        assertThat("Number of routes is incorrect!", context.getRoutes().size(), is(equalTo(1)));
+        assertThat("Configured route is incorrect!", context.getRouteStatus("simple"), is(equalTo(ServiceStatus.Started)));
+    }
+
+    @Test
+    @InSequence(2)
+    public void addManualRoute(CamelContext context) throws Exception {
+        context.addRoutes(builder);
+
+        assertThat("Number of routes is incorrect!", context.getRoutes().size(), is(equalTo(2)));
+        assertThat("Configured route is incorrect!", context.getRouteStatus("manual"), is(equalTo(ServiceStatus.Started)));
+    }
+
+    @Test
+    @InSequence(3)
+    public void sendMessageToInbound() throws InterruptedException {
+        outbound.expectedMessageCount(1);
+        outbound.expectedBodiesReceived("test");
+
+        inbound.sendBody("test");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, outbound);
+    }
+
+    @Test
+    @InSequence(4)
+    public void sendMessageToManual() throws InterruptedException {
+        mock.expectedMessageCount(1);
+        mock.expectedBodiesReceived("manual");
+
+        manual.sendBody("manual");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, mock);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MockEndpointTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MockEndpointTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MockEndpointTest.java
new file mode 100644
index 0000000..7bf0ba7
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MockEndpointTest.java
@@ -0,0 +1,84 @@
+/**
+ * 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.cdi.test;
+
+import java.util.concurrent.TimeUnit;
+import javax.inject.Inject;
+
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.Mock;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.bean.DefaultCamelContextBean;
+import org.apache.camel.cdi.bean.MockAnnotationRoute;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Arquillian.class)
+public class MockEndpointTest {
+
+    @Inject
+    private DefaultCamelContextBean defaultCamelContext;
+
+    @Inject
+    @Uri("direct:start")
+    private ProducerTemplate defaultInbound;
+
+    @Inject
+    @Mock("mock:result")
+    private MockEndpoint defaultOutbound;
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test classes
+            .addClasses(DefaultCamelContextBean.class, MockAnnotationRoute.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    public void verifyCamelContext() {
+        assertThat(defaultCamelContext.getName(), is(equalTo("camel-cdi")));
+        assertThat(defaultOutbound.getCamelContext().getName(), is(equalTo(defaultCamelContext.getName())));
+    }
+
+    @Test
+    public void sendMessageToInbound() throws InterruptedException {
+        defaultOutbound.expectedMessageCount(1);
+        defaultOutbound.expectedBodiesReceived("test");
+        defaultOutbound.expectedHeaderReceived("foo", "bar");
+
+        defaultInbound.sendBodyAndHeader("test", "foo", "bar");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, defaultOutbound);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiCamelContextProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiCamelContextProducerTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiCamelContextProducerTest.java
new file mode 100644
index 0000000..ebfbf70
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiCamelContextProducerTest.java
@@ -0,0 +1,168 @@
+/**
+ * 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.cdi.test;
+
+import java.util.concurrent.TimeUnit;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.ContextName;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.bean.DefaultCamelContextBean;
+import org.apache.camel.cdi.bean.FirstCamelContextRoute;
+import org.apache.camel.cdi.bean.UriEndpointRoute;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.junit.InSequence;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.apache.camel.cdi.expression.ExchangeExpression.fromCamelContext;
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Arquillian.class)
+public class MultiCamelContextProducerTest {
+
+    @Produces
+    @ApplicationScoped
+    @ContextName("first")
+    private static CamelContext firstContext = new DefaultCamelContext();
+
+    @Inject
+    // Support bean class injection for custom beans
+    private DefaultCamelContextBean defaultCamelContext;
+
+    @Inject @Uri("direct:inbound")
+    private ProducerTemplate defaultInbound;
+
+    @Inject @Uri("mock:outbound")
+    private MockEndpoint defaultOutbound;
+
+    @Inject @ContextName("first")
+    private CamelContext firstCamelContext;
+
+    @Inject @ContextName("first") @Uri("direct:inbound")
+    private ProducerTemplate firstInbound;
+
+    @Inject @ContextName("first") @Uri("mock:outbound")
+    private MockEndpoint firstOutbound;
+
+    @Inject @ContextName("second")
+    private CamelContext secondCamelContext;
+
+    @Inject @ContextName("second") @Uri("direct:inbound")
+    private ProducerTemplate secondInbound;
+
+    @Inject @ContextName("second") @Uri("mock:outbound")
+    private MockEndpoint secondOutbound;
+
+    @Produces
+    @ApplicationScoped
+    @ContextName("second")
+    private static CamelContext secondContext() {
+        return new DefaultCamelContext();
+    }
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test classes
+            .addClasses(
+                DefaultCamelContextBean.class,
+                UriEndpointRoute.class,
+                FirstCamelContextRoute.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    @InSequence(1)
+    public void verifyCamelContexts() {
+        assertThat(defaultCamelContext.getName(), is(equalTo("camel-cdi")));
+        assertThat(firstCamelContext.getName(), is(equalTo("first")));
+        assertThat(secondCamelContext.getName(), is(equalTo("second")));
+
+        assertThat(defaultOutbound.getCamelContext().getName(), is(equalTo(defaultCamelContext.getName())));
+        assertThat(firstOutbound.getCamelContext().getName(), is(equalTo(firstCamelContext.getName())));
+        assertThat(secondOutbound.getCamelContext().getName(), is(equalTo(secondCamelContext.getName())));
+    }
+
+    @Test
+    @InSequence(2)
+    public void configureCamelContexts() throws Exception {
+        secondCamelContext.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:inbound").setHeader("context").constant("second").to("mock:outbound");
+            }
+        });
+    }
+
+    @Test
+    @InSequence(3)
+    public void sendMessageToDefaultCamelContextInbound() throws InterruptedException {
+        defaultOutbound.expectedMessageCount(1);
+        defaultOutbound.expectedBodiesReceived("test-default");
+        defaultOutbound.message(0).exchange().matches(fromCamelContext("camel-cdi"));
+
+        defaultInbound.sendBody("test-default");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, defaultOutbound);
+    }
+
+    @Test
+    @InSequence(4)
+    public void sendMessageToFirstCamelContextInbound() throws InterruptedException {
+        firstOutbound.expectedMessageCount(1);
+        firstOutbound.expectedBodiesReceived("test-first");
+        firstOutbound.expectedHeaderReceived("context", "first");
+        firstOutbound.message(0).exchange().matches(fromCamelContext("first"));
+
+        firstInbound.sendBody("test-first");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, firstOutbound);
+    }
+
+    @Test
+    @InSequence(5)
+    public void sendMessageToSecondCamelContextInbound() throws InterruptedException {
+        secondOutbound.expectedMessageCount(1);
+        secondOutbound.expectedBodiesReceived("test-second");
+        secondOutbound.expectedHeaderReceived("context", "second");
+        secondOutbound.message(0).exchange().matches(fromCamelContext("second"));
+
+        secondInbound.sendBody("test-second");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, secondOutbound);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiCamelContextTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiCamelContextTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiCamelContextTest.java
new file mode 100644
index 0000000..2eafb09
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiCamelContextTest.java
@@ -0,0 +1,159 @@
+/**
+ * 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.cdi.test;
+
+import java.util.concurrent.TimeUnit;
+import javax.inject.Inject;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.ContextName;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.bean.DefaultCamelContextBean;
+import org.apache.camel.cdi.bean.FirstCamelContextBean;
+import org.apache.camel.cdi.bean.FirstCamelContextRoute;
+import org.apache.camel.cdi.bean.SecondCamelContextBean;
+import org.apache.camel.cdi.bean.UriEndpointRoute;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.junit.InSequence;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.apache.camel.cdi.expression.ExchangeExpression.fromCamelContext;
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Arquillian.class)
+public class MultiCamelContextTest {
+
+    @Inject
+    // Support bean class injection for custom beans
+    private DefaultCamelContextBean defaultCamelContext;
+
+    @Inject @Uri("direct:inbound")
+    private ProducerTemplate defaultInbound;
+
+    @Inject @Uri("mock:outbound")
+    private MockEndpoint defaultOutbound;
+
+    @Inject @ContextName("first")
+    private CamelContext firstCamelContext;
+
+    @Inject @ContextName("first") @Uri("direct:inbound")
+    private ProducerTemplate firstInbound;
+
+    @Inject @ContextName("first") @Uri("mock:outbound")
+    private MockEndpoint firstOutbound;
+
+    @Inject @ContextName("second")
+    private CamelContext secondCamelContext;
+
+    @Inject @ContextName("second") @Uri("direct:inbound")
+    private ProducerTemplate secondInbound;
+
+    @Inject @ContextName("second") @Uri("mock:outbound")
+    private MockEndpoint secondOutbound;
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test classes
+            .addClasses(
+                DefaultCamelContextBean.class,
+                UriEndpointRoute.class,
+                FirstCamelContextBean.class,
+                FirstCamelContextRoute.class,
+                SecondCamelContextBean.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    @InSequence(1)
+    public void verifyCamelContexts() {
+        assertThat(defaultCamelContext.getName(), is(equalTo("camel-cdi")));
+        assertThat(firstCamelContext.getName(), is(equalTo("first")));
+        assertThat(secondCamelContext.getName(), is(equalTo("second")));
+
+        assertThat(defaultOutbound.getCamelContext().getName(), is(equalTo(defaultCamelContext.getName())));
+        assertThat(firstOutbound.getCamelContext().getName(), is(equalTo(firstCamelContext.getName())));
+        assertThat(secondOutbound.getCamelContext().getName(), is(equalTo(secondCamelContext.getName())));
+    }
+
+    @Test
+    @InSequence(2)
+    public void configureCamelContexts() throws Exception {
+        secondCamelContext.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:inbound").setHeader("context").constant("second").to("mock:outbound");
+            }
+        });
+
+        secondCamelContext.startAllRoutes();
+    }
+
+    @Test
+    @InSequence(3)
+    public void sendMessageToDefaultCamelContextInbound() throws InterruptedException {
+        defaultOutbound.expectedMessageCount(1);
+        defaultOutbound.expectedBodiesReceived("test-default");
+        defaultOutbound.message(0).exchange().matches(fromCamelContext("camel-cdi"));
+
+        defaultInbound.sendBody("test-default");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, defaultOutbound);
+    }
+
+    @Test
+    @InSequence(4)
+    public void sendMessageToFirstCamelContextInbound() throws InterruptedException {
+        firstOutbound.expectedMessageCount(1);
+        firstOutbound.expectedBodiesReceived("test-first");
+        firstOutbound.expectedHeaderReceived("context", "first");
+        firstOutbound.message(0).exchange().matches(fromCamelContext("first"));
+
+        firstInbound.sendBody("test-first");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, firstOutbound);
+    }
+
+    @Test
+    @InSequence(5)
+    public void sendMessageToSecondCamelContextInbound() throws InterruptedException {
+        secondOutbound.expectedMessageCount(1);
+        secondOutbound.expectedBodiesReceived("test-second");
+        secondOutbound.expectedHeaderReceived("context", "second");
+        secondOutbound.message(0).exchange().matches(fromCamelContext("second"));
+
+        secondInbound.sendBody("test-second");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, secondOutbound);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextEndpointInjectTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextEndpointInjectTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextEndpointInjectTest.java
new file mode 100644
index 0000000..5ce8eb3
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextEndpointInjectTest.java
@@ -0,0 +1,137 @@
+/**
+ * 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.cdi.test;
+
+import java.util.concurrent.TimeUnit;
+import javax.inject.Inject;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.ContextName;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.bean.DefaultCamelContextBean;
+import org.apache.camel.cdi.bean.EndpointInjectRoute;
+import org.apache.camel.cdi.bean.FirstCamelContextBean;
+import org.apache.camel.cdi.bean.FirstCamelContextEndpointInjectRoute;
+import org.apache.camel.cdi.bean.SecondCamelContextBean;
+import org.apache.camel.cdi.bean.SecondCamelContextEndpointInjectRoute;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.junit.InSequence;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.apache.camel.cdi.expression.ExchangeExpression.fromCamelContext;
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+
+@RunWith(Arquillian.class)
+public class MultiContextEndpointInjectTest {
+
+    @Inject
+    private CamelContext defaultCamelContext;
+
+    @Inject @Uri("direct:inbound")
+    private ProducerTemplate defaultInbound;
+
+    @Inject @Uri("mock:outbound")
+    private MockEndpoint defaultOutbound;
+
+    @Inject @ContextName("first")
+    private CamelContext firstCamelContext;
+
+    @Inject @ContextName("first") @Uri("direct:inbound")
+    private ProducerTemplate firstInbound;
+
+    @Inject @ContextName("first") @Uri("mock:outbound")
+    private MockEndpoint firstOutbound;
+
+    @Inject @ContextName("second")
+    private CamelContext secondCamelContext;
+
+    @Inject @ContextName("second") @Uri("direct:inbound")
+    private ProducerTemplate secondInbound;
+
+    @Inject @ContextName("second") @Uri("mock:outbound")
+    private MockEndpoint secondOutbound;
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test classes
+            .addClasses(
+                DefaultCamelContextBean.class,
+                EndpointInjectRoute.class,
+                FirstCamelContextBean.class,
+                FirstCamelContextEndpointInjectRoute.class,
+                SecondCamelContextBean.class,
+                SecondCamelContextEndpointInjectRoute.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    @InSequence(1)
+    public void configureCamelContexts() throws Exception {
+        secondCamelContext.startAllRoutes();
+    }
+
+    @Test
+    @InSequence(2)
+    public void sendMessageToDefaultCamelContextInbound() throws InterruptedException {
+        defaultOutbound.expectedMessageCount(1);
+        defaultOutbound.expectedBodiesReceived("test-default");
+        defaultOutbound.message(0).exchange().matches(fromCamelContext("camel-cdi"));
+
+        defaultInbound.sendBody("test-default");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, defaultOutbound);
+    }
+
+    @Test
+    @InSequence(3)
+    public void sendMessageToFirstCamelContextInbound() throws InterruptedException {
+        firstOutbound.expectedMessageCount(1);
+        firstOutbound.expectedBodiesReceived("test-first");
+        firstOutbound.expectedHeaderReceived("context", "first");
+        firstOutbound.message(0).exchange().matches(fromCamelContext("first"));
+
+        firstInbound.sendBody("test-first");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, firstOutbound);
+    }
+
+    @Test
+    @InSequence(4)
+    public void sendMessageToSecondCamelContextInbound() throws InterruptedException {
+        secondOutbound.expectedMessageCount(1);
+        secondOutbound.expectedBodiesReceived("test-second");
+        secondOutbound.expectedHeaderReceived("context", "second");
+        secondOutbound.message(0).exchange().matches(fromCamelContext("second"));
+
+        secondInbound.sendBody("test-second");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, secondOutbound);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextEventEndpointTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextEventEndpointTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextEventEndpointTest.java
new file mode 100644
index 0000000..c6b51af
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextEventEndpointTest.java
@@ -0,0 +1,190 @@
+/**
+ * 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.cdi.test;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.event.Event;
+import javax.enterprise.event.Observes;
+import javax.inject.Inject;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.ContextName;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.bean.FirstCamelContextBean;
+import org.apache.camel.cdi.bean.FirstCamelContextEventConsumingRoute;
+import org.apache.camel.cdi.bean.FirstCamelContextEventProducingRoute;
+import org.apache.camel.cdi.bean.SecondCamelContextBean;
+import org.apache.camel.cdi.bean.SecondCamelContextEventConsumingRoute;
+import org.apache.camel.cdi.bean.SecondCamelContextEventProducingRoute;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.hamcrest.Matchers;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.junit.InSequence;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+import static org.hamcrest.Matchers.contains;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Arquillian.class)
+public class MultiContextEventEndpointTest {
+
+    @Inject
+    @ContextName("first")
+    @Uri("mock:consumeString")
+    private MockEndpoint firstConsumeString;
+
+    @Inject
+    @ContextName("second")
+    @Uri("mock:consumeString")
+    private MockEndpoint secondConsumeString;
+
+    @Inject
+    @ContextName("first")
+    @Uri("direct:produceString")
+    private ProducerTemplate firstProduceString;
+
+    @Inject
+    @ContextName("second")
+    @Uri("direct:produceString")
+    private ProducerTemplate secondProduceString;
+
+    @Inject
+    private Event<Object> objectEvent;
+
+    @Inject
+    private EventObserver observer;
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test classes
+            .addClasses(
+                FirstCamelContextBean.class,
+                FirstCamelContextEventConsumingRoute.class,
+                FirstCamelContextEventProducingRoute.class,
+                SecondCamelContextBean.class,
+                SecondCamelContextEventConsumingRoute.class,
+                SecondCamelContextEventProducingRoute.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    @InSequence(1)
+    public void configureCamelContexts(@ContextName("second") CamelContext secondContext) throws Exception {
+        secondContext.startAllRoutes();
+    }
+
+    @Test
+    @InSequence(2)
+    public void sendEventsToConsumers() throws InterruptedException {
+        firstConsumeString.expectedMessageCount(1);
+        firstConsumeString.expectedBodiesReceived("testFirst");
+
+        secondConsumeString.expectedMessageCount(2);
+        secondConsumeString.expectedBodiesReceived("testSecond1", "testSecond2");
+
+        objectEvent.select(String.class, new ContextName.Literal("first")).fire("testFirst");
+        objectEvent.select(String.class, new ContextName.Literal("second")).fire("testSecond1");
+        objectEvent.select(String.class, new ContextName.Literal("second")).fire("testSecond2");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, firstConsumeString, secondConsumeString);
+    }
+
+    @Test
+    @InSequence(3)
+    public void sendMessagesToProducers() {
+        firstProduceString.sendBody("testFirst");
+        secondProduceString.sendBody("testSecond");
+
+        assertThat(observer.getObjectEvents(), Matchers.<Object>contains("testFirst", "testSecond"));
+        assertThat(observer.getStringEvents(), contains("testFirst", "testSecond"));
+        assertThat(observer.getFirstStringEvents(), contains("testFirst"));
+        assertThat(observer.secondStringEvents(), contains("testSecond"));
+    }
+
+    @Before
+    public void resetCollectedEvents() {
+        observer.reset();
+    }
+
+    @ApplicationScoped
+    static class EventObserver {
+
+        private final List<Object> objectEvents = new ArrayList<>();
+
+        private final List<String> stringEvents = new ArrayList<>();
+
+        private final List<String> firstStringEvents = new ArrayList<>();
+
+        private final List<String> secondStringEvents = new ArrayList<>();
+
+        void collectObjectEvents(@Observes Object event) {
+            objectEvents.add(event);
+        }
+
+        void collectStringEvents(@Observes String event) {
+            stringEvents.add(event);
+        }
+
+        void collectFirstStringEvents(@Observes @ContextName("first") String event) {
+            firstStringEvents.add(event);
+        }
+
+        void collectSecondStringEvents(@Observes @ContextName("second") String event) {
+            secondStringEvents.add(event);
+        }
+
+        List<Object> getObjectEvents() {
+            return objectEvents;
+        }
+
+        List<String> getStringEvents() {
+            return stringEvents;
+        }
+
+        List<String> getFirstStringEvents() {
+            return firstStringEvents;
+        }
+
+        List<String> secondStringEvents() {
+            return secondStringEvents;
+        }
+
+        void reset() {
+            objectEvents.clear();
+            stringEvents.clear();
+            firstStringEvents.clear();
+            secondStringEvents.clear();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextEventNotifierTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextEventNotifierTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextEventNotifierTest.java
new file mode 100644
index 0000000..57d24fe
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextEventNotifierTest.java
@@ -0,0 +1,300 @@
+/**
+ * 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.cdi.test;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.Default;
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.ContextName;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.bean.DefaultCamelContextBean;
+import org.apache.camel.cdi.bean.FirstCamelContextBean;
+import org.apache.camel.cdi.bean.FirstCamelContextRoute;
+import org.apache.camel.cdi.bean.SecondCamelContextBean;
+import org.apache.camel.cdi.bean.UriEndpointRoute;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.management.event.AbstractExchangeEvent;
+import org.apache.camel.management.event.CamelContextStartedEvent;
+import org.apache.camel.management.event.CamelContextStartingEvent;
+import org.apache.camel.management.event.ExchangeCompletedEvent;
+import org.apache.camel.management.event.ExchangeCreatedEvent;
+import org.apache.camel.management.event.ExchangeSendingEvent;
+import org.apache.camel.management.event.ExchangeSentEvent;
+import org.hamcrest.Matchers;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.junit.InSequence;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.apache.camel.cdi.expression.ExchangeExpression.fromCamelContext;
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+import static org.hamcrest.Matchers.everyItem;
+import static org.hamcrest.Matchers.hasSize;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Arquillian.class)
+public class MultiContextEventNotifierTest {
+
+    @Inject
+    // Support bean class injection for custom beans
+    private DefaultCamelContextBean defaultCamelContext;
+
+    @Inject @Uri("direct:inbound")
+    private ProducerTemplate defaultInbound;
+
+    @Inject @Uri("mock:outbound")
+    private MockEndpoint defaultOutbound;
+
+    @Produces @ApplicationScoped
+    private List<Class> defaultFiredEvents = new ArrayList<>();
+
+
+    @Inject @ContextName("first")
+    private CamelContext firstCamelContext;
+
+    @Inject @ContextName("first") @Uri("direct:inbound")
+    private ProducerTemplate firstInbound;
+
+    @Inject @ContextName("first") @Uri("mock:outbound")
+    private MockEndpoint firstOutbound;
+
+    @Produces @ApplicationScoped @ContextName("first")
+    private List<Class> firstFiredEvents = new ArrayList<>();
+
+
+    @Inject @ContextName("second")
+    private CamelContext secondCamelContext;
+
+    @Inject @ContextName("second") @Uri("direct:inbound")
+    private ProducerTemplate secondInbound;
+
+    @Inject @ContextName("second") @Uri("mock:outbound")
+    private MockEndpoint secondOutbound;
+
+    @Produces @ApplicationScoped @ContextName("second")
+    private List<Class> secondFiredEvents = new ArrayList<>();
+
+
+    @Produces @ApplicationScoped @Any @Named("anyContext")
+    private List<Class> anyFiredEvents = new ArrayList<>();
+
+
+    private void onAnyContextStartingEvent(@Observes CamelContextStartingEvent event, @Named("anyContext") List<Class> events) {
+        events.add(CamelContextStartingEvent.class);
+    }
+
+    private void onAnyContextStartedEvent(@Observes CamelContextStartedEvent event, @Named("anyContext") List<Class> events) {
+        events.add(CamelContextStartedEvent.class);
+    }
+
+    private void onAnyExchangeEvent(@Observes AbstractExchangeEvent event, @Named("anyContext") List<Class> events) {
+        events.add(event.getClass());
+    }
+
+
+    private void onDefaultContextStartingEvent(@Observes @Default CamelContextStartingEvent event, List<Class> events) {
+        events.add(CamelContextStartingEvent.class);
+    }
+
+    private void onDefaultContextStartedEvent(@Observes @Default CamelContextStartedEvent event, List<Class> events) {
+        events.add(CamelContextStartedEvent.class);
+    }
+
+    private void onDefaultExchangeEvent(@Observes @Default AbstractExchangeEvent event, List<Class> events) {
+        events.add(event.getClass());
+    }
+
+
+    private void onFirstContextStartingEvent(@Observes @ContextName("first") CamelContextStartingEvent event, @ContextName("first") List<Class> events) {
+        events.add(CamelContextStartingEvent.class);
+    }
+
+    private void onFirstContextStartedEvent(@Observes @ContextName("first") CamelContextStartedEvent event, @ContextName("first") List<Class> events) {
+        events.add(CamelContextStartedEvent.class);
+    }
+
+    private void onFirstExchangeEvent(@Observes @ContextName("first") AbstractExchangeEvent event, @ContextName("first") List<Class> events) {
+        events.add(event.getClass());
+    }
+
+
+    private void onSecondContextStartingEvent(@Observes @ContextName("second") CamelContextStartingEvent event, @ContextName("second") List<Class> events) {
+        events.add(CamelContextStartingEvent.class);
+    }
+
+    private void onSecondContextStartedEvent(@Observes @ContextName("second") CamelContextStartedEvent event, @ContextName("second") List<Class> events) {
+        events.add(CamelContextStartedEvent.class);
+    }
+
+    private void onSecondExchangeEvent(@Observes @ContextName("second") AbstractExchangeEvent event, @ContextName("second") List<Class> events) {
+        events.add(event.getClass());
+    }
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test classes
+            .addClasses(
+                DefaultCamelContextBean.class,
+                UriEndpointRoute.class,
+                FirstCamelContextBean.class,
+                FirstCamelContextRoute.class,
+                SecondCamelContextBean.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    @InSequence(1)
+    public void configureCamelContexts(List<Class> defaultEvents,
+                                       @ContextName("first") List<Class> firstEvents,
+                                       @ContextName("second") List<Class> secondEvents,
+                                       @Named("anyContext") List<Class> anyEvents) throws Exception {
+        secondCamelContext.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:inbound").setHeader("context").constant("second").to("mock:outbound");
+            }
+        });
+
+        secondCamelContext.startAllRoutes();
+
+        assertThat("Events fired for any contexts are incorrect", anyEvents,
+            everyItem(
+                Matchers.<Class>isOneOf(
+                    CamelContextStartingEvent.class,
+                    CamelContextStartedEvent.class)));
+        assertThat("Events fired for default context are incorrect", defaultEvents,
+            Matchers.<Class>contains(
+                CamelContextStartingEvent.class,
+                CamelContextStartedEvent.class));
+        assertThat("Events fired for first context are incorrect", firstEvents,
+            Matchers.<Class>contains(
+                CamelContextStartingEvent.class,
+                CamelContextStartedEvent.class));
+        assertThat("Events fired for second context are incorrect", secondEvents,
+            Matchers.<Class>contains(
+                CamelContextStartingEvent.class,
+                CamelContextStartedEvent.class));
+    }
+
+    @Test
+    @InSequence(2)
+    public void sendMessageToDefaultCamelContextInbound(List<Class> events) throws InterruptedException {
+        defaultOutbound.expectedMessageCount(1);
+        defaultOutbound.expectedBodiesReceived("test-default");
+        defaultOutbound.message(0).exchange().matches(fromCamelContext("camel-cdi"));
+
+        defaultInbound.sendBody("test-default");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, defaultOutbound);
+
+        assertThat("Events fired are incorrect", events,
+            Matchers.<Class>contains(
+                CamelContextStartingEvent.class,
+                CamelContextStartedEvent.class,
+                ExchangeSendingEvent.class,
+                ExchangeCreatedEvent.class,
+                ExchangeSendingEvent.class,
+                ExchangeSentEvent.class,
+                ExchangeCompletedEvent.class,
+                ExchangeSentEvent.class));
+    }
+
+    @Test
+    @InSequence(3)
+    public void sendMessageToFirstCamelContextInbound(@ContextName("first") List<Class> events) throws InterruptedException {
+        firstOutbound.expectedMessageCount(1);
+        firstOutbound.expectedBodiesReceived("test-first");
+        firstOutbound.expectedHeaderReceived("context", "first");
+        firstOutbound.message(0).exchange().matches(fromCamelContext("first"));
+
+        firstInbound.sendBody("test-first");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, firstOutbound);
+
+        assertThat("Events fired are incorrect", events,
+            Matchers.<Class>contains(
+                CamelContextStartingEvent.class,
+                CamelContextStartedEvent.class,
+                ExchangeSendingEvent.class,
+                ExchangeCreatedEvent.class,
+                ExchangeSendingEvent.class,
+                ExchangeSentEvent.class,
+                ExchangeCompletedEvent.class,
+                ExchangeSentEvent.class));
+    }
+
+    @Test
+    @InSequence(4)
+    public void sendMessageToSecondCamelContextInbound(@ContextName("second") List<Class> events) throws InterruptedException {
+        secondOutbound.expectedMessageCount(1);
+        secondOutbound.expectedBodiesReceived("test-second");
+        secondOutbound.expectedHeaderReceived("context", "second");
+        secondOutbound.message(0).exchange().matches(fromCamelContext("second"));
+
+        secondInbound.sendBody("test-second");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, secondOutbound);
+
+        assertThat("Events fired are incorrect", events,
+            Matchers.<Class>contains(
+                CamelContextStartingEvent.class,
+                CamelContextStartedEvent.class,
+                ExchangeSendingEvent.class,
+                ExchangeCreatedEvent.class,
+                ExchangeSendingEvent.class,
+                ExchangeSentEvent.class,
+                ExchangeCompletedEvent.class,
+                ExchangeSentEvent.class));
+    }
+
+    @Test
+    @InSequence(5)
+    public void stopCamelContexts(List<Class> defaultEvents,
+                                  @ContextName("first") List<Class> firstEvents,
+                                  @ContextName("second") List<Class> secondEvents,
+                                  @Named("anyContext") List<Class> anyEvents) throws Exception {
+        defaultCamelContext.stop();
+        firstCamelContext.stop();
+        secondCamelContext.stop();
+
+        assertThat("Events count fired for default context are incorrect", defaultEvents, hasSize(8));
+        assertThat("Events count fired for first context are incorrect", firstEvents, hasSize(8));
+        assertThat("Events count fired for second context are incorrect", secondEvents, hasSize(8));
+        assertThat("Events count fired for any contexts are incorrect", anyEvents, hasSize(24));
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextProduceTemplateTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextProduceTemplateTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextProduceTemplateTest.java
new file mode 100644
index 0000000..730c065
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextProduceTemplateTest.java
@@ -0,0 +1,157 @@
+/**
+ * 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.cdi.test;
+
+import java.util.concurrent.TimeUnit;
+import javax.inject.Inject;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.ContextName;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.bean.DefaultCamelContextBean;
+import org.apache.camel.cdi.bean.FirstCamelContextBean;
+import org.apache.camel.cdi.bean.FirstCamelContextProduceTemplateBean;
+import org.apache.camel.cdi.bean.ProduceTemplateBean;
+import org.apache.camel.cdi.bean.SecondCamelContextBean;
+import org.apache.camel.cdi.bean.SecondCamelContextProduceTemplateBean;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.junit.InSequence;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.apache.camel.cdi.expression.ExchangeExpression.fromCamelContext;
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+
+@RunWith(Arquillian.class)
+public class MultiContextProduceTemplateTest {
+
+    @Inject
+    private CamelContext defaultCamelContext;
+
+    @Inject @Uri("direct:inbound")
+    private ProducerTemplate defaultInbound;
+
+    @Inject @Uri("mock:outbound")
+    private MockEndpoint defaultOutbound;
+
+    @Inject @ContextName("first")
+    private CamelContext firstCamelContext;
+
+    @Inject @ContextName("first") @Uri("direct:inbound")
+    private ProducerTemplate firstInbound;
+
+    @Inject @ContextName("first") @Uri("mock:outbound")
+    private MockEndpoint firstOutbound;
+
+    @Inject @ContextName("second")
+    private CamelContext secondCamelContext;
+
+    @Inject @ContextName("second") @Uri("direct:inbound")
+    private ProducerTemplate secondInbound;
+
+    @Inject @ContextName("second") @Uri("mock:outbound")
+    private MockEndpoint secondOutbound;
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test classes
+            .addClasses(
+                DefaultCamelContextBean.class,
+                ProduceTemplateBean.class,
+                FirstCamelContextBean.class,
+                FirstCamelContextProduceTemplateBean.class,
+                SecondCamelContextBean.class,
+                SecondCamelContextProduceTemplateBean.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    @InSequence(1)
+    public void configureCamelContexts() throws Exception {
+        defaultCamelContext.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:inbound").bean(ProduceTemplateBean.class);
+            }
+        });
+
+        firstCamelContext.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:inbound").bean(FirstCamelContextProduceTemplateBean.class);
+            }
+        });
+
+        secondCamelContext.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:inbound").bean(SecondCamelContextProduceTemplateBean.class);
+            }
+        });
+
+        secondCamelContext.startAllRoutes();
+    }
+
+    @Test
+    @InSequence(2)
+    public void sendMessageToDefaultCamelContextInbound() throws InterruptedException {
+        defaultOutbound.expectedMessageCount(1);
+        defaultOutbound.expectedBodiesReceived("test-processed");
+        defaultOutbound.message(0).exchange().matches(fromCamelContext("camel-cdi"));
+
+        defaultInbound.sendBody("test");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, defaultOutbound);
+    }
+
+    @Test
+    @InSequence(3)
+    public void sendMessageToFirstCamelContextInbound() throws InterruptedException {
+        firstOutbound.expectedMessageCount(1);
+        firstOutbound.expectedBodiesReceived("test-first");
+        firstOutbound.message(0).exchange().matches(fromCamelContext("first"));
+
+        firstInbound.sendBody("test");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, firstOutbound);
+    }
+
+    @Test
+    @InSequence(4)
+    public void sendMessageToSecondCamelContextInbound() throws InterruptedException {
+        secondOutbound.expectedMessageCount(1);
+        secondOutbound.expectedBodiesReceived("test-second");
+        secondOutbound.message(0).exchange().matches(fromCamelContext("second"));
+
+        secondInbound.sendBody("test");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, secondOutbound);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextPropertyInjectTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextPropertyInjectTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextPropertyInjectTest.java
new file mode 100644
index 0000000..024a304
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextPropertyInjectTest.java
@@ -0,0 +1,193 @@
+/**
+ * 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.cdi.test;
+
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.ContextName;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.bean.DefaultCamelContextBean;
+import org.apache.camel.cdi.bean.FirstCamelContextBean;
+import org.apache.camel.cdi.bean.FirstCamelContextPropertyInjectBean;
+import org.apache.camel.cdi.bean.PropertyInjectBean;
+import org.apache.camel.cdi.bean.SecondCamelContextBean;
+import org.apache.camel.cdi.bean.SecondCamelContextPropertyInjectBean;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.properties.PropertiesComponent;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.junit.InSequence;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Arquillian.class)
+public class MultiContextPropertyInjectTest {
+
+    @Inject
+    private CamelContext defaultCamelContext;
+
+    @Inject @Uri("direct:in")
+    private ProducerTemplate defaultInbound;
+
+    @Inject @Uri("mock:out")
+    private MockEndpoint defaultOutbound;
+
+    @Inject @ContextName("first")
+    private CamelContext firstCamelContext;
+
+    @Inject @ContextName("first") @Uri("direct:in")
+    private ProducerTemplate firstInbound;
+
+    @Inject @ContextName("first") @Uri("mock:out")
+    private MockEndpoint firstOutbound;
+
+    @Inject @ContextName("second")
+    private CamelContext secondCamelContext;
+
+    @Inject @ContextName("second") @Uri("direct:in")
+    private ProducerTemplate secondInbound;
+
+    @Inject @ContextName("second") @Uri("mock:out")
+    private MockEndpoint secondOutbound;
+
+    @Produces
+    @ApplicationScoped
+    @Named("properties")
+    private static PropertiesComponent configuration() {
+        Properties properties = new Properties();
+        properties.put("property", "default");
+        PropertiesComponent component = new PropertiesComponent();
+        component.setInitialProperties(properties);
+        return component;
+    }
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test classes
+            .addClasses(
+                DefaultCamelContextBean.class,
+                PropertyInjectBean.class,
+                FirstCamelContextBean.class,
+                FirstCamelContextPropertyInjectBean.class,
+                SecondCamelContextBean.class,
+                SecondCamelContextPropertyInjectBean.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    @InSequence(1)
+    public void configureCamelContexts() throws Exception {
+        defaultCamelContext.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:in").bean(PropertyInjectBean.class).to("mock:out");
+            }
+        });
+
+        firstCamelContext.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:in").bean(FirstCamelContextPropertyInjectBean.class).to("mock:out");
+            }
+        });
+
+        secondCamelContext.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:in").bean(SecondCamelContextPropertyInjectBean.class).to("mock:out");
+            }
+        });
+
+        secondCamelContext.startAllRoutes();
+    }
+
+    @Test
+    @InSequence(2)
+    public void sendMessageToDefaultCamelContextInbound() throws InterruptedException {
+        defaultOutbound.expectedMessageCount(1);
+        defaultOutbound.expectedBodiesReceived("test");
+        defaultOutbound.expectedHeaderReceived("header", "default");
+
+        defaultInbound.sendBody("test");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, defaultOutbound);
+    }
+
+    @Test
+    @InSequence(3)
+    public void retrieveReferenceFromDefaultCamelContext(PropertyInjectBean bean) {
+        assertThat(bean.getProperty(), is(equalTo("default")));
+    }
+
+    @Test
+    @InSequence(4)
+    public void sendMessageToFirstCamelContextInbound() throws InterruptedException {
+        firstOutbound.expectedMessageCount(1);
+        firstOutbound.expectedBodiesReceived("test");
+        firstOutbound.expectedHeaderReceived("header", "default");
+
+        firstInbound.sendBody("test");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, firstOutbound);
+    }
+
+    @Test
+    @InSequence(5)
+    public void retrieveReferenceFromFirstCamelContext(FirstCamelContextPropertyInjectBean bean) {
+        assertThat(bean.getProperty(), is(equalTo("default")));
+    }
+
+    @Test
+    @InSequence(6)
+    public void sendMessageToSecondCamelContextInbound() throws InterruptedException {
+        secondOutbound.expectedMessageCount(1);
+        secondOutbound.expectedBodiesReceived("test");
+        secondOutbound.expectedHeaderReceived("header", "default");
+
+        secondInbound.sendBody("test");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, secondOutbound);
+    }
+
+    @Test
+    @InSequence(7)
+    public void retrieveReferenceFromSecondCamelContext(SecondCamelContextPropertyInjectBean bean) {
+        assertThat(bean.getProperty(), is(equalTo("default")));
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/NamedCamelBeanTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/NamedCamelBeanTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/NamedCamelBeanTest.java
new file mode 100644
index 0000000..cb93c55
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/NamedCamelBeanTest.java
@@ -0,0 +1,75 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cdi.test;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.bean.NamedCamelBean;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.junit.InSequence;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+
+@RunWith(Arquillian.class)
+public class NamedCamelBeanTest {
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test class
+            .addClass(NamedCamelBean.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    @InSequence(1)
+    public void configureCamelContext(CamelContext context) throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:inbound").bean("beanName").to("mock:outbound");
+            }
+        });
+    }
+
+    @Test
+    @InSequence(2)
+    public void sendMessageToInbound(@Uri("direct:inbound") ProducerTemplate in, @Uri("mock:outbound") MockEndpoint out) throws InterruptedException {
+        out.expectedMessageCount(1);
+        out.expectedBodiesReceived("test-processed");
+        
+        in.sendBody("test");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, out);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/NamedCamelContextTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/NamedCamelContextTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/NamedCamelContextTest.java
new file mode 100644
index 0000000..92adb38
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/NamedCamelContextTest.java
@@ -0,0 +1,114 @@
+/**
+ * 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.cdi.test;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Instance;
+import javax.enterprise.inject.Produces;
+import javax.inject.Named;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasProperty;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Arquillian.class)
+public class NamedCamelContextTest {
+
+    @Named
+    @Produces
+    @ApplicationScoped
+    private CamelContext emptyNamedFieldContext = new DefaultCamelContext();
+
+    @Produces
+    @ApplicationScoped
+    @Named("named-field-context")
+    private CamelContext namedFieldContext = new DefaultCamelContext();
+
+    @Named
+    @Produces
+    @ApplicationScoped
+    private CamelContext getEmptyNamedGetterContext() {
+        return new DefaultCamelContext();
+    }
+
+    @Named
+    @Produces
+    @ApplicationScoped
+    private CamelContext getEmptyNamedMethodContext() {
+        return new DefaultCamelContext();
+    }
+
+    @Produces
+    @ApplicationScoped
+    @Named("named-getter-context")
+    private CamelContext getNamedGetterContext() {
+        return new DefaultCamelContext();
+    }
+
+    @Produces
+    @ApplicationScoped
+    @Named("named-method-context")
+    private CamelContext getNamedMethodContext() {
+        return new DefaultCamelContext();
+    }
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    public void verifyCamelContexts(Instance<CamelContext> contexts) {
+        assertThat(contexts, containsInAnyOrder(
+            hasProperty("name", equalTo("emptyNamedFieldContext")),
+            hasProperty("name", equalTo("emptyNamedGetterContext")),
+            hasProperty("name", equalTo("emptyNamedMethodContext")),
+            hasProperty("name", equalTo("named-field-context")),
+            hasProperty("name", equalTo("named-getter-context")),
+            hasProperty("name", equalTo("named-method-context")),
+            hasProperty("name", equalTo("emptyNamedBeanContext")),
+            hasProperty("name", equalTo("named-bean-context"))
+        ));
+    }
+
+    @Named
+    @ApplicationScoped
+    static class EmptyNamedBeanContext extends DefaultCamelContext {
+    }
+
+    @ApplicationScoped
+    @Named("named-bean-context")
+    static class NamedBeanContext extends DefaultCamelContext {
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/ProduceTemplateTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/ProduceTemplateTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/ProduceTemplateTest.java
new file mode 100644
index 0000000..77e9cef
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/ProduceTemplateTest.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.apache.camel.cdi.test;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.bean.ProduceTemplateBean;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.junit.InSequence;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+
+@RunWith(Arquillian.class)
+public class ProduceTemplateTest {
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test class
+            .addClass(ProduceTemplateBean.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    @InSequence(1)
+    public void configureCamelContext(CamelContext context) throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:inbound").bean(ProduceTemplateBean.class);
+            }
+        });
+    }
+
+    @Test
+    @InSequence(2)
+    public void sendMessageToInbound(@Uri("direct:inbound") ProducerTemplate in,
+                                     @Uri("mock:outbound") MockEndpoint out) throws InterruptedException {
+        out.expectedMessageCount(1);
+        out.expectedBodiesReceived("test-processed");
+        
+        in.sendBody("test");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, out);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/PropertiesLocationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/PropertiesLocationTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/PropertiesLocationTest.java
new file mode 100644
index 0000000..a6ec82f
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/PropertiesLocationTest.java
@@ -0,0 +1,102 @@
+/**
+ * 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.cdi.test;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+import javax.inject.Named;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.component.properties.PropertiesComponent;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.OperateOnDeployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Arquillian.class)
+public class PropertiesLocationTest {
+
+    @Deployment(name = "single-location")
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test class
+            .addClass(SingleLocation.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    // TODO: reactivate when ARQ-1255 is fixed
+    /*
+    @Deployment(name = "multiple-locations")
+    public static Archive<?> multipleLocationsDeployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test classes
+            .addClass(MultipleLocations.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+    */
+
+    @Test
+    @OperateOnDeployment("single-location")
+    public void resolvePropertyFromLocation(CamelContext context) throws Exception {
+        assertThat("Property from classpath location does not resolve!", context.resolvePropertyPlaceholders("{{header.message}}"), is(equalTo("message from file")));
+    }
+
+    /*
+    @Test
+    @OperateOnDeployment("multiple-locations")
+    public void resolvePropertyFromLocations(CamelContext context) throws Exception {
+        assertThat("Property from classpath locations does not resolve!", context.resolvePropertyPlaceholders("{{foo.property}}"), is(equalTo("foo.value")));
+        assertThat("Property from classpath locations does not resolve!", context.resolvePropertyPlaceholders("{{bar.property}}"), is(equalTo("bar.value")));
+    }
+    */
+}
+
+class SingleLocation {
+
+    @Produces
+    @ApplicationScoped
+    @Named("properties")
+    private static PropertiesComponent configuration() {
+        return new PropertiesComponent("classpath:placeholder.properties");
+    }
+}
+
+class MultipleLocations {
+
+    @Produces
+    @ApplicationScoped
+    @Named("properties")
+    private static PropertiesComponent configuration() {
+        return new PropertiesComponent("classpath:foo.properties", "classpath:bar.properties");
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/PropertiesMultipleLocationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/PropertiesMultipleLocationTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/PropertiesMultipleLocationTest.java
new file mode 100644
index 0000000..3f038a4
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/PropertiesMultipleLocationTest.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.apache.camel.cdi.test;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.OperateOnDeployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Arquillian.class)
+public class PropertiesMultipleLocationTest {
+
+    @Deployment(name = "multiple-locations")
+    public static Archive<?> multipleLocationsDeployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test class
+            .addClass(MultipleLocations.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    @OperateOnDeployment("multiple-locations")
+    public void resolvePropertyFromLocations(CamelContext context) throws Exception {
+        assertThat("Property from classpath locations does not resolve!", context.resolvePropertyPlaceholders("{{foo.property}}"), is(equalTo("foo.value")));
+        assertThat("Property from classpath locations does not resolve!", context.resolvePropertyPlaceholders("{{bar.property}}"), is(equalTo("bar.value")));
+    }
+}


[7/9] camel git commit: CAMEL-9201: Improved Camel CDI component

Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/Mock.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/Mock.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/Mock.java
index 27e9650..bcc4500 100644
--- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/Mock.java
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/Mock.java
@@ -25,21 +25,31 @@ import javax.inject.Qualifier;
 
 /**
  * A qualifier for injecting instances of {@link org.apache.camel.component.mock.MockEndpoint} into a bean.
+ *
+ * @deprecated Use {@link org.apache.camel.cdi.Uri} instead:
+ *
+ * <pre><code>
+ * {@literal @}Inject
+ * {@literal @}Uri("mock:outbound")
+ * MockEndpoint mock;
+ * </code></pre>
  */
+@Deprecated
 @Qualifier
 @Retention(RetentionPolicy.RUNTIME)
 @Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER})
 public @interface Mock {
 
     /**
-     * Returns an optional URI used to create the MockEndpoint
+     * Returns an optional URI used to create the {@code MockEndpoint}.
      */
     @Nonbinding
     String value() default "";
 
     /**
-     * Returns the name of the CamelContext to use to resolve the endpoint for this URI
+     * Returns the name of the Camel context to use to resolve the {@code MockEndpoint}.
      */
     @Nonbinding
     String context() default "";
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/RoutesXml.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/RoutesXml.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/RoutesXml.java
index 48f6377..aa83263 100644
--- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/RoutesXml.java
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/RoutesXml.java
@@ -85,4 +85,4 @@ public final class RoutesXml {
         return loadRoutesFromFile(camelContext, new File(fileName));
     }
 
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/Uri.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/Uri.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/Uri.java
old mode 100644
new mode 100755
index 0d320f1..0fff3d1
--- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/Uri.java
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/Uri.java
@@ -24,20 +24,18 @@ import javax.enterprise.util.Nonbinding;
 import javax.inject.Qualifier;
 
 /**
- * An injection annotation to define the <a href="http://camel.apache.org/uris.html">Camel URI</a> used
- * to reference the underlying <a href="http://camel.apache.org/endpoint.html">Camel Endpoint</a>.
+ * A CDI qualifier to define the <a href="http://camel.apache.org/uris.html">Camel URI</a> associated to
+ * the annotated resource. This annotation can be used to annotate an {@code @Inject} injection point for
+ * values of type {@link org.apache.camel.Endpoint} or {@link org.apache.camel.ProducerTemplate}. For example:
+ * <pre><code>
+ * {@literal @}Inject
+ * {@literal @}Uri("mock:foo")
+ * Endpoint endpoint;
  *
- * This annotation can be used to annotate an @Inject injection point for values of type
- * {@link org.apache.camel.Endpoint} or {@link org.apache.camel.ProducerTemplate} with a String URI.
- *
- * For example:
- * <code>
- *     public class Foo {
- *         @Inject @Uri("mock:foo") Endpoint endpoint;
- *
- *         @Inject @Uri("seda:bar") ProducerTemplate producer;
- *     }
- * </code>
+ * {@literal @}Inject
+ * {@literal @}Uri("seda:bar")
+ * ProducerTemplate producer;
+ * </code></pre>
  */
 @Qualifier
 @Retention(RetentionPolicy.RUNTIME)
@@ -45,14 +43,21 @@ import javax.inject.Qualifier;
 public @interface Uri {
 
     /**
-     * Returns the <a href="http://camel.apache.org/uris.html">Camel URI</a> of the endpoint
+     * Returns the <a href="http://camel.apache.org/uris.html">Camel URI</a> of the resource.
      */
-    @Nonbinding
-    String value();
+    @Nonbinding String value();
 
     /**
-     * Returns the name of the CamelContext to use to resolve the endpoint for this URI
+     * Returns the name of the {@code CamelContext} to use to resolve the Camel resource for this URI.
+     *
+     * @deprecated Use the {@link ContextName} qualifier to specify the name of the {@code CamelContext} instead:
+     * <pre><code>
+     * {@literal @}Inject
+     * {@literal @}ContextName("foo")
+     * {@literal @}Uri("seda:bar")
+     * Endpoint endpoint;
+     * </code></pre>
      */
-    @Nonbinding
-    String context() default "";
+    @Deprecated
+    @Nonbinding String context() default "";
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/Vetoed.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/Vetoed.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/Vetoed.java
new file mode 100644
index 0000000..b6bd5cb
--- /dev/null
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/Vetoed.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.apache.camel.cdi;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * Annotation to veto an {@code AnnotatedType} for CDI 1.1+ backward compatibility.
+ */
+@Documented
+@Target(value = { TYPE })
+@Retention(value = RUNTIME)
+@interface Vetoed {
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/component/properties/CdiPropertiesComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/component/properties/CdiPropertiesComponent.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/component/properties/CdiPropertiesComponent.java
deleted file mode 100644
index 921f6a1..0000000
--- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/component/properties/CdiPropertiesComponent.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi.component.properties;
-
-import javax.inject.Named;
-
-import org.apache.camel.component.properties.PropertiesComponent;
-
-/**
- * Simple extension for properties component which uses custom property resolver.
- */
-@Named("properties")
-public class CdiPropertiesComponent extends PropertiesComponent {
-
-    public CdiPropertiesComponent() {
-        setPropertiesParser(new CdiPropertiesParser(this));
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/component/properties/CdiPropertiesParser.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/component/properties/CdiPropertiesParser.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/component/properties/CdiPropertiesParser.java
deleted file mode 100644
index e9cde59..0000000
--- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/component/properties/CdiPropertiesParser.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi.component.properties;
-
-import java.util.Properties;
-
-import org.apache.camel.component.properties.DefaultPropertiesParser;
-import org.apache.camel.component.properties.PropertiesComponent;
-import org.apache.deltaspike.core.api.config.ConfigResolver;
-
-/**
- * Properties parser which uses {@link ConfigResolver} from deltaspike to obtain
- * configuration properties. If property is not recognized by deltaspike execution
- * will be delegated to parent implementation.
- */
-public class CdiPropertiesParser extends DefaultPropertiesParser {
-
-    public CdiPropertiesParser(PropertiesComponent propertiesComponent) {
-        super(propertiesComponent);
-    }
-
-    @Override
-    public String parseProperty(String key, String value, Properties properties) {
-        String answer = ConfigResolver.getPropertyValue(key);
-
-        if (answer != null) {
-            return answer;
-        }
-
-        return super.parseProperty(key, value, properties);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/BeanAdapter.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/BeanAdapter.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/BeanAdapter.java
deleted file mode 100644
index 3bab39a..0000000
--- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/BeanAdapter.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi.internal;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.camel.Consume;
-import org.apache.camel.EndpointInject;
-import org.apache.camel.Produce;
-import org.apache.camel.cdi.ContextName;
-import org.apache.camel.impl.DefaultCamelBeanPostProcessor;
-
-/**
- * Contains the bean and the consume methods
- */
-public class BeanAdapter {
-    
-    private final List<Method> consumeMethods = new ArrayList<Method>();
-    private final List<Method> produceMethods = new ArrayList<Method>();
-    private final List<Method> endpointMethods = new ArrayList<Method>();
-    private final List<Field> produceFields = new ArrayList<Field>();
-    private final List<Field> endpointFields = new ArrayList<Field>();
-    private final ContextName startup;
-
-    public BeanAdapter(ContextName startup) {
-        this.startup = startup;
-    }
-
-    /**
-     * Returns true if this adapter is empty (i.e. has no custom adapter code)
-     */
-    public boolean isEmpty() {
-        return consumeMethods.isEmpty() && produceMethods.isEmpty() && produceFields.isEmpty() 
-            && endpointMethods.isEmpty() && endpointFields.isEmpty();
-    }
-
-    public void addConsumeMethod(Method method) {
-        consumeMethods.add(method);
-    }
-
-    public void addProduceMethod(Method method) {
-        produceMethods.add(method);
-    }
-
-    public void addProduceField(Field field) {
-        produceFields.add(field);
-    }
-
-    public void addEndpointField(Field field) {
-        endpointFields.add(field);
-    }
-
-    public void addEndpointMethod(Method method) {
-        endpointMethods.add(method);
-    }
-
-    /**
-     * Perform injections
-     */
-    public void inject(CamelExtension camelExtension, Object reference, String beanName) {
-        for (Method method : consumeMethods) {
-            Consume annotation = method.getAnnotation(Consume.class);
-            if (annotation != null) {
-                String contextName = CamelExtension.getCamelContextName(annotation.context(), startup);
-                DefaultCamelBeanPostProcessor postProcessor = camelExtension.getPostProcessor(contextName, null);
-                if (postProcessor != null) {
-                    postProcessor.getPostProcessorHelper().consumerInjection(method, reference, beanName);
-                }
-            }
-        }
-        for (Method method : produceMethods) {
-            Produce annotation = method.getAnnotation(Produce.class);
-            if (annotation != null) {
-                String contextName = CamelExtension.getCamelContextName(annotation.context(), startup);
-                DefaultCamelBeanPostProcessor postProcessor = camelExtension.getPostProcessor(contextName, null);
-                if (postProcessor != null && postProcessor.getPostProcessorHelper().matchContext(contextName)) {
-                    postProcessor.setterInjection(method, reference, beanName, annotation.uri(), annotation.ref(),
-                            annotation.property());
-                }
-            }
-        }
-        for (Method method : endpointMethods) {
-            EndpointInject annotation = method.getAnnotation(EndpointInject.class);
-            if (annotation != null) {
-                String contextName = CamelExtension.getCamelContextName(annotation.context(), startup);
-                DefaultCamelBeanPostProcessor postProcessor = camelExtension.getPostProcessor(contextName, null);
-                if (postProcessor != null && postProcessor.getPostProcessorHelper().matchContext(contextName)) {
-                    postProcessor.setterInjection(method, reference, beanName, annotation.uri(), annotation.ref(),
-                            annotation.property());
-
-                }
-            }
-        }
-        for (Field field : produceFields) {
-            Produce annotation = field.getAnnotation(Produce.class);
-            if (annotation != null) {
-                String contextName = CamelExtension.getCamelContextName(annotation.context(), startup);
-                DefaultCamelBeanPostProcessor postProcessor = camelExtension.getPostProcessor(contextName, null);
-                if (postProcessor != null && postProcessor.getPostProcessorHelper().matchContext(contextName)) {
-                    postProcessor.injectField(field, annotation.uri(), annotation.ref(),
-                            annotation.property(), reference, beanName);
-                }
-            }
-        }
-        for (Field field : endpointFields) {
-            EndpointInject annotation = field.getAnnotation(EndpointInject.class);
-            String contextName = CamelExtension.getCamelContextName(annotation.context(), startup);
-            DefaultCamelBeanPostProcessor postProcessor = camelExtension.getPostProcessor(contextName, null);
-            if (postProcessor != null && postProcessor.getPostProcessorHelper().matchContext(contextName)) {
-                postProcessor.injectField(field, annotation.uri(), annotation.ref(),
-                        annotation.property(), reference, beanName);
-            }
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelContextBean.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelContextBean.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelContextBean.java
deleted file mode 100644
index 1ea5159..0000000
--- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelContextBean.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi.internal;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.enterprise.inject.spi.InjectionPoint;
-import javax.enterprise.inject.spi.InjectionTarget;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.cdi.CdiCamelContext;
-import org.apache.camel.util.ObjectHelper;
-import org.apache.deltaspike.core.api.literal.AnyLiteral;
-import org.apache.deltaspike.core.api.literal.DefaultLiteral;
-
-/**
- * Description of camel context bean.
- */
-public class CamelContextBean implements Bean<CdiCamelContext> {
-
-    private final BeanManager beanManager;
-    private final String name;
-    private final String camelContextName;
-    private final InjectionTarget<CdiCamelContext> target;
-    private final CamelContextConfig config;
-
-    public CamelContextBean(BeanManager beanManager) {
-        this(beanManager, "CamelContext", "", new CamelContextConfig());
-    }
-
-    public CamelContextBean(BeanManager beanManager, String name, String camelContextName,
-                            CamelContextConfig config) {
-        this.beanManager = beanManager;
-        this.name = name;
-        this.camelContextName = camelContextName;
-        this.config = config;
-        this.target = beanManager.createInjectionTarget(beanManager.createAnnotatedType(CdiCamelContext.class));
-    }
-
-    @Override
-    public CdiCamelContext create(CreationalContext<CdiCamelContext> context) {
-        // create CdiCamelContext and set its name
-        CdiCamelContext camelContext = target.produce(context);
-        if (ObjectHelper.isNotEmpty(camelContextName)) {
-            camelContext.setName(camelContextName);
-        }
-
-        // then do dependency injection
-        target.inject(camelContext, context);
-
-        // and post construct which will start Camel
-        target.postConstruct(camelContext);
-
-        context.push(camelContext);
-        return camelContext;
-    }
-
-    @Override
-    public void destroy(CdiCamelContext instance, CreationalContext<CdiCamelContext> context) {
-        target.preDestroy(instance);
-        target.dispose(instance);
-        context.release();
-    }
-
-    @Override
-    public Set<Type> getTypes() {
-        return new HashSet<Type>(Arrays.asList(Object.class, CamelContext.class, CdiCamelContext.class));
-    }
-
-    @Override
-    public Set<Annotation> getQualifiers() {
-        return new HashSet<Annotation>(Arrays.asList(new DefaultLiteral(), new AnyLiteral()));
-    }
-
-    @Override
-    public Class<? extends Annotation> getScope() {
-        return ApplicationScoped.class;
-    }
-
-    @Override
-    public String getName() {
-        return name;
-    }
-
-    @Override
-    public boolean isNullable() {
-        return false;
-    }
-
-    @Override
-    public Set<InjectionPoint> getInjectionPoints() {
-        return target.getInjectionPoints();
-    }
-
-    @Override
-    public Class<?> getBeanClass() {
-        return CdiCamelContext.class;
-    }
-
-    @Override
-    public Set<Class<? extends Annotation>> getStereotypes() {
-        return new HashSet<Class<? extends Annotation>>();
-    }
-
-    @Override
-    public boolean isAlternative() {
-        return false;
-    }
-
-    public String getCamelContextName() {
-        return camelContextName;
-    }
-
-    public void configureCamelContext(CdiCamelContext camelContext) {
-        config.configure(camelContext, beanManager);
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelContextConfig.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelContextConfig.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelContextConfig.java
deleted file mode 100644
index 65c92ac..0000000
--- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelContextConfig.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi.internal;
-
-import java.lang.reflect.Type;
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.inject.spi.AnnotatedType;
-import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.BeanManager;
-
-import org.apache.camel.RoutesBuilder;
-import org.apache.camel.RuntimeCamelException;
-import org.apache.camel.cdi.CdiCamelContext;
-import org.apache.camel.model.RouteContainer;
-import org.apache.camel.util.ObjectHelper;
-
-/**
- * Configuration options to be applied to a {@link org.apache.camel.CamelContext} by a {@link CamelContextBean}
- */
-public class CamelContextConfig {
-    // use a set to avoid duplicates
-    private final Set<Bean<?>> routeBuilderBeans = new LinkedHashSet<Bean<?>>();
-    private final Set<AnnotatedType<?>> patRouteBuilders = new LinkedHashSet<AnnotatedType<?>>();
-
-    public void addRouteBuilderBean(Bean<?> bean) {
-        routeBuilderBeans.add(bean);
-    }
-
-    public void configure(CdiCamelContext camelContext, BeanManager beanManager) {
-        for (AnnotatedType<?> pat : patRouteBuilders) {
-            final Set<Bean<?>> beans = beanManager.getBeans(pat.getJavaClass());
-            final Bean<?> bean = beanManager.resolve(beans);
-            routeBuilderBeans.add(bean);
-        }
-        patRouteBuilders.clear();
-
-        for (Bean<?> bean : routeBuilderBeans) {
-            CreationalContext<?> createContext = beanManager.createCreationalContext(bean);
-            Class<?> beanClass = bean.getBeanClass();
-            Set<Type> types = bean.getTypes();
-            for (Type type : types) {
-                // lets use the first type for producer methods
-                if (type instanceof Class<?>) {
-                    beanClass = (Class<?>) type;
-                    break;
-                }
-            }
-            Object reference = beanManager.getReference(bean, beanClass, createContext);
-            ObjectHelper.notNull(reference, "Could not instantiate bean of type: " + beanClass.getName() + " for " + bean);
-            try {
-                // we should not toString reference instance as in CDI it may be proxied
-                if (reference instanceof RoutesBuilder) {
-                    RoutesBuilder routeBuilder = (RoutesBuilder)reference;
-                    camelContext.addRoutes(routeBuilder);
-                } else if (reference instanceof RouteContainer) {
-                    RouteContainer routeContainer = (RouteContainer)reference;
-                    camelContext.addRouteDefinitions(routeContainer.getRoutes());
-                } else {
-                    throw new IllegalArgumentException("Invalid route builder of type: " + beanClass.getName()
-                            + ". Should be RoutesBuilder or RoutesContainer");
-                }
-            } catch (Exception e) {
-                throw new RuntimeCamelException("Error adding route builder of type: " + beanClass.getName()
-                        + " to CamelContext: " + camelContext.getName() + " due " + e.getMessage(), e);
-            }
-        }
-    }
-
-    public void addRouteBuilderBean(final AnnotatedType<?> process) {
-        patRouteBuilders.add(process);
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelContextMap.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelContextMap.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelContextMap.java
deleted file mode 100644
index b2d5487..0000000
--- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelContextMap.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi.internal;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.annotation.PostConstruct;
-import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.inject.Instance;
-import javax.inject.Inject;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.util.ObjectHelper;
-
-/**
- * A helper class to be able to resolve CamelContext instances by their name
- */
-@ApplicationScoped
-public class CamelContextMap {
-    @Inject
-    private Instance<CamelContext> camelContexts;
-
-    private Map<String, CamelContext> camelContextMap = new HashMap<String, CamelContext>();
-
-    @PostConstruct
-    public void start() {
-        ObjectHelper.notNull(camelContexts, "camelContexts");
-
-        Iterator<CamelContext> iterator = camelContexts.iterator();
-        while (iterator.hasNext()) {
-            CamelContext camelContext = iterator.next();
-            camelContextMap.put(camelContext.getName(), camelContext);
-        }
-    }
-
-    /**
-     * Returns the {@link CamelContext} for the given context name
-     */
-    public CamelContext getCamelContext(String name) {
-        CamelContext answer = camelContextMap.get(name);
-        if (answer == null && ObjectHelper.isEmpty(name)) {
-            // lets return the first one for the default context?
-            Collection<CamelContext> values = camelContextMap.values();
-            for (CamelContext value : values) {
-                answer = value;
-                break;
-            }
-        }
-        return answer;
-
-    }
-
-    /**
-     * Returns the CamelContext for the given name or throw an exception
-     */
-    public CamelContext getMandatoryCamelContext(String contextName) {
-        CamelContext camelContext = getCamelContext(contextName);
-        ObjectHelper.notNull(camelContext, "No CamelContext found for name '" + contextName + "' when available names are " + camelContextMap.keySet());
-        return camelContext;
-    }
-
-    public Map<String, CamelContext> getCamelContextMap() {
-        return camelContextMap;
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelExtension.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelExtension.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelExtension.java
deleted file mode 100644
index a9c715b..0000000
--- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelExtension.java
+++ /dev/null
@@ -1,342 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi.internal;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.spi.AfterBeanDiscovery;
-import javax.enterprise.inject.spi.AfterDeploymentValidation;
-import javax.enterprise.inject.spi.Annotated;
-import javax.enterprise.inject.spi.AnnotatedType;
-import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.enterprise.inject.spi.Extension;
-import javax.enterprise.inject.spi.InjectionTarget;
-import javax.enterprise.inject.spi.ProcessAnnotatedType;
-import javax.enterprise.inject.spi.ProcessBean;
-import javax.enterprise.inject.spi.ProcessInjectionTarget;
-import javax.enterprise.inject.spi.ProcessProducerMethod;
-import javax.enterprise.util.AnnotationLiteral;
-import javax.inject.Inject;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.CamelContextAware;
-import org.apache.camel.Consume;
-import org.apache.camel.EndpointInject;
-import org.apache.camel.Produce;
-import org.apache.camel.RoutesBuilder;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.cdi.CdiBeanManagerHelper;
-import org.apache.camel.cdi.CdiCamelContext;
-import org.apache.camel.cdi.ContextName;
-import org.apache.camel.impl.DefaultCamelBeanPostProcessor;
-import org.apache.camel.model.RouteContainer;
-import org.apache.camel.util.ObjectHelper;
-import org.apache.camel.util.ReflectionHelper;
-import org.apache.deltaspike.core.util.metadata.builder.AnnotatedTypeBuilder;
-
-/**
- * Set of camel specific hooks for CDI.
- */
-public class CamelExtension implements Extension {
-
-    private static class InjectLiteral extends AnnotationLiteral<Inject> {
-        private static final long serialVersionUID = 1L;
-    }
-
-    @Inject
-    BeanManager beanManager;
-
-    private CamelContextMap camelContextMap;
-    private final Set<Bean<?>> eagerBeans = new HashSet<Bean<?>>();
-    private final Map<String, CamelContextConfig> camelContextConfigMap = new HashMap<String, CamelContextConfig>();
-    private final List<CamelContextBean> camelContextBeans = new ArrayList<CamelContextBean>();
-
-    public CamelExtension() {
-    }
-
-    /**
-     * If no context name is specified then default it to the value from
-     * the {@link org.apache.camel.cdi.ContextName} annotation
-     */
-    public static String getCamelContextName(String context, ContextName annotation) {
-        if (ObjectHelper.isEmpty(context) && annotation != null) {
-            return annotation.value();
-        }
-        return context;
-    }
-
-    /**
-     * Process camel context aware bean definitions.
-     *
-     * @param process Annotated type.
-     * @throws Exception In case of exceptions.
-     */
-    protected void contextAwareness(@Observes ProcessAnnotatedType<CamelContextAware> process) throws Exception {
-        AnnotatedType<CamelContextAware> at = process.getAnnotatedType();
-
-        Method method = at.getJavaClass().getMethod("setCamelContext", CamelContext.class);
-        AnnotatedTypeBuilder<CamelContextAware> builder = new AnnotatedTypeBuilder<CamelContextAware>()
-                .readFromType(at)
-                .addToMethod(method, new InjectLiteral());
-        process.setAnnotatedType(builder.create());
-    }
-
-    protected void detectRouteBuilders(@Observes ProcessAnnotatedType<?> process) throws Exception {
-        AnnotatedType<?> annotatedType = process.getAnnotatedType();
-        ContextName annotation = annotatedType.getAnnotation(ContextName.class);
-        Class<?> javaClass = annotatedType.getJavaClass();
-        if (annotation != null && isRoutesBean(javaClass)) {
-            addRouteBuilderBean(annotatedType, annotation);
-        }
-    }
-
-    private void addRouteBuilderBean(final AnnotatedType<?> process, ContextName annotation) {
-        final CamelContextConfig config = getCamelConfig(annotation.value());
-        config.addRouteBuilderBean(process);
-    }
-
-    /**
-     * Disable creation of default CamelContext bean and rely on context created
-     * and managed by extension.
-     *
-     * @param process Annotated type.
-     */
-    protected void disableDefaultContext(@Observes ProcessAnnotatedType<? extends CamelContext> process) {
-        process.veto();
-    }
-
-    /**
-     * Registers managed camel bean.
-     *
-     * @param abd     After bean discovery event.
-     * @param manager Bean manager.
-     */
-    protected void registerManagedCamelContext(@Observes AfterBeanDiscovery abd, BeanManager manager) {
-        // lets ensure we have at least one camel context
-        if (camelContextConfigMap.isEmpty()) {
-            abd.addBean(new CamelContextBean(manager));
-        } else {
-            Set<Map.Entry<String, CamelContextConfig>> entries = camelContextConfigMap.entrySet();
-            for (Map.Entry<String, CamelContextConfig> entry : entries) {
-                String name = entry.getKey();
-                CamelContextConfig config = entry.getValue();
-                CamelContextBean camelContextBean = new CamelContextBean(manager, "CamelContext:" + name, name, config);
-                camelContextBeans.add(camelContextBean);
-                abd.addBean(camelContextBean);
-            }
-        }
-    }
-
-    /**
-     * Lets detect all beans annotated with @Consume so they can be auto-registered
-     */
-    public void detectConsumeBeans(@Observes ProcessBean<?> event) {
-        final Bean<?> bean = event.getBean();
-        Class<?> beanClass = bean.getBeanClass();
-        ReflectionHelper.doWithMethods(beanClass, new ReflectionHelper.MethodCallback() {
-            @Override
-            public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
-                Consume consume = method.getAnnotation(Consume.class);
-                if (consume != null) {
-                    eagerBeans.add(bean);
-                }
-            }
-        });
-    }
-
-    /**
-     * Lets detect all beans annotated of type {@link RouteBuilder}
-     * which are annotated with {@link org.apache.camel.cdi.ContextName}
-     * so they can be auto-registered
-     */
-    public void detectRouteBuilderBeans(@Observes ProcessBean<?> event) {
-        final Bean<?> bean = event.getBean();
-        Class<?> beanClass = bean.getBeanClass();
-        if (isRoutesBean(beanClass)) {
-            addRouteBuilderBean(bean, beanClass.getAnnotation(ContextName.class));
-        }
-    }
-
-    private void addRouteBuilderBean(Bean<?> bean, ContextName annotation) {
-        if (annotation != null) {
-            String contextName = annotation.value();
-            CamelContextConfig config = getCamelConfig(contextName);
-            config.addRouteBuilderBean(bean);
-        }
-    }
-
-    private CamelContextConfig getCamelConfig(final String contextName) {
-        CamelContextConfig config = camelContextConfigMap.get(contextName);
-        if (config == null) {
-            config = new CamelContextConfig();
-            camelContextConfigMap.put(contextName, config);
-        }
-        return config;
-    }
-
-    /**
-     * Lets detect all producer methods creating instances of {@link RouteBuilder} which are annotated with
-     * {@link org.apache.camel.cdi.ContextName} so they can be auto-registered
-     */
-    public void detectProducerRoutes(@Observes ProcessProducerMethod<?, ?> event) {
-        Annotated annotated = event.getAnnotated();
-        ContextName annotation = annotated.getAnnotation(ContextName.class);
-        Class<?> returnType = event.getAnnotatedProducerMethod().getJavaMember().getReturnType();
-        if (isRoutesBean(returnType)) {
-            addRouteBuilderBean(event.getBean(), annotation);
-        }
-    }
-
-    /**
-     * Lets force the CDI container to create all beans annotated with @Consume so that the consumer becomes active
-     */
-    public void startConsumeBeans(@Observes AfterDeploymentValidation event, BeanManager beanManager) throws Exception {
-        for (CamelContextBean bean : camelContextBeans) {
-            String name = bean.getCamelContextName();
-            CamelContext context = getCamelContext(name, beanManager);
-            if (context == null) {
-                throw new IllegalStateException(
-                        "CamelContext '" + name + "' has not been injected into the CamelContextMap");
-            }
-            bean.configureCamelContext((CdiCamelContext) context);
-        }
-
-        for (Bean<?> bean : eagerBeans) {
-            // force lazy creation to start the consumer
-            CreationalContext<?> creationalContext = beanManager.createCreationalContext(bean);
-            beanManager.getReference(bean, bean.getBeanClass(), creationalContext);
-        }
-    }
-
-    /**
-     * Lets perform injection of all beans which use Camel annotations
-     */
-    @SuppressWarnings("unchecked")
-    public void onInjectionTarget(@Observes ProcessInjectionTarget<?> event) {
-        final InjectionTarget injectionTarget = event.getInjectionTarget();
-        AnnotatedType annotatedType = event.getAnnotatedType();
-        final Class<Object> beanClass = annotatedType.getJavaClass();
-        // TODO this is a bit of a hack - what should the bean name be?
-        final String beanName = injectionTarget.toString();
-        ContextName contextName = annotatedType.getAnnotation(ContextName.class);
-        final BeanAdapter adapter = createBeanAdapter(beanClass, contextName);
-        if (!adapter.isEmpty()) {
-            DelegateInjectionTarget newTarget = new DelegateInjectionTarget(injectionTarget) {
-                @Override
-                public void inject(Object instance, CreationalContext ctx) {
-                    super.inject(instance, ctx);
-
-                    // now lets inject our Camel injections to the bean instance
-                    adapter.inject(CamelExtension.this, instance, beanName);
-                }
-            };
-            event.setInjectionTarget(newTarget);
-        }
-    }
-
-    /**
-     * Perform injection on an existing bean such as a test case which is created directly by a testing framework.
-     * <p/>
-     * This is because BeanProvider.injectFields() does not invoke the onInjectionTarget() method so the injection
-     * of @Produce / @EndpointInject and processing of the @Consume annotations are not performed.
-     */
-    public void inject(Object bean) {
-        Class<?> beanClass = bean.getClass();
-        ContextName contextName = beanClass.getAnnotation(ContextName.class);
-        final BeanAdapter adapter = createBeanAdapter(beanClass, contextName);
-        if (!adapter.isEmpty()) {
-            // TODO this is a bit of a hack - what should the bean name be?
-            final String beanName = bean.toString();
-            adapter.inject(this, bean, beanName);
-        }
-    }
-
-    private BeanAdapter createBeanAdapter(Class<?> beanClass, ContextName contextName) {
-        final BeanAdapter adapter = new BeanAdapter(contextName);
-        ReflectionHelper.doWithFields(beanClass, new ReflectionHelper.FieldCallback() {
-            @Override
-            public void doWith(Field field) throws IllegalArgumentException, IllegalAccessException {
-                Produce produce = field.getAnnotation(Produce.class);
-                if (produce != null && !injectAnnotatedField(field)) {
-                    adapter.addProduceField(field);
-                }
-                EndpointInject endpointInject = field.getAnnotation(EndpointInject.class);
-                if (endpointInject != null) {
-                    adapter.addEndpointField(field);
-                }
-            }
-        });
-        ReflectionHelper.doWithMethods(beanClass, new ReflectionHelper.MethodCallback() {
-            @Override
-            public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
-                Consume consume = method.getAnnotation(Consume.class);
-                if (consume != null) {
-                    adapter.addConsumeMethod(method);
-                }
-                Produce produce = method.getAnnotation(Produce.class);
-                if (produce != null) {
-                    adapter.addProduceMethod(method);
-                }
-                EndpointInject endpointInject = method.getAnnotation(EndpointInject.class);
-                if (endpointInject != null) {
-                    adapter.addEndpointMethod(method);
-                }
-            }
-        });
-        return adapter;
-    }
-
-    protected DefaultCamelBeanPostProcessor getPostProcessor(String context, BeanManager beanManager) {
-        CamelContext camelContext = getCamelContext(context, beanManager);
-        if (camelContext != null) {
-            return new DefaultCamelBeanPostProcessor(camelContext);
-        } else {
-            throw new IllegalArgumentException("No such CamelContext '" + context + "' available!");
-        }
-    }
-
-    protected CamelContext getCamelContext(String context, BeanManager beanManager) {
-        BeanManager manager = this.beanManager != null ? this.beanManager : beanManager;
-        if (camelContextMap == null && manager != null) {
-            camelContextMap = CdiBeanManagerHelper.lookupBeanByType(manager, CamelContextMap.class);
-        }
-        ObjectHelper.notNull(camelContextMap, "Could not resolve CamelContextMap");
-        return camelContextMap.getCamelContext(context);
-    }
-
-    /**
-     * Returns true if this field is annotated with @Inject
-     */
-    protected static boolean injectAnnotatedField(Field field) {
-        return field.getAnnotation(Inject.class) != null;
-    }
-
-    protected boolean isRoutesBean(Class<?> returnType) {
-        return (RoutesBuilder.class.isAssignableFrom(returnType) || RouteContainer.class.isAssignableFrom(returnType))
-            && !Modifier.isAbstract(returnType.getModifiers());
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelFactory.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelFactory.java
deleted file mode 100644
index d79dd6c..0000000
--- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelFactory.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi.internal;
-
-import javax.enterprise.inject.Produces;
-import javax.enterprise.inject.spi.Annotated;
-import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.InjectionPoint;
-import javax.inject.Inject;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.Endpoint;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.cdi.ContextName;
-import org.apache.camel.cdi.Mock;
-import org.apache.camel.cdi.Uri;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.util.CamelContextHelper;
-import org.apache.camel.util.ObjectHelper;
-
-/**
- * Produces {@link Endpoint} and {@link org.apache.camel.ProducerTemplate} instances for injection into beans
- */
-public class CamelFactory {
-    @Inject CamelContextMap camelContextMap;
-
-    @Produces
-    @Mock
-    public MockEndpoint createMockEndpoint(InjectionPoint point) {
-        Mock annotation = point.getAnnotated().getAnnotation(Mock.class);
-        ObjectHelper.notNull(annotation, "Should be annotated with @Mock");
-        String uri = annotation.value();
-        if (ObjectHelper.isEmpty(uri)) {
-            uri = "mock:" + point.getMember().getName();
-        }
-        return CamelContextHelper.getMandatoryEndpoint(getCamelContext(point, annotation.context()), uri, MockEndpoint.class);
-    }
-
-    @Produces
-    @Uri("")
-    public Endpoint createEndpoint(InjectionPoint point) {
-        Annotated annotated = point.getAnnotated();
-        Uri uri = annotated.getAnnotation(Uri.class);
-        ObjectHelper.notNull(uri, "Should be annotated with @Uri");
-        return CamelContextHelper.getMandatoryEndpoint(getCamelContext(point, uri.context()), uri.value());
-    }
-
-    @Produces
-    @Uri("")
-    public ProducerTemplate createProducerTemplate(InjectionPoint point) {
-        Annotated annotated = point.getAnnotated();
-        Uri uri = annotated.getAnnotation(Uri.class);
-        CamelContext camelContext = getCamelContext(point, uri.context());
-        ProducerTemplate producerTemplate = camelContext.createProducerTemplate();
-        ObjectHelper.notNull(uri, "Should be annotated with @Uri");
-        Endpoint endpoint = CamelContextHelper.getMandatoryEndpoint(camelContext, uri.value());
-        producerTemplate.setDefaultEndpoint(endpoint);
-        return producerTemplate;
-    }
-
-    protected CamelContext getCamelContext(InjectionPoint point, String contextName) {
-        ContextName startup = point.getAnnotated().getAnnotation(ContextName.class);
-        if (startup == null) {
-            Bean<?> bean = point.getBean();
-            if (bean != null) {
-                startup = bean.getBeanClass().getAnnotation(ContextName.class);
-            }
-        }
-        String name = CamelExtension.getCamelContextName(contextName, startup);
-        return camelContextMap.getMandatoryCamelContext(name);
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/DelegateInjectionTarget.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/DelegateInjectionTarget.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/DelegateInjectionTarget.java
deleted file mode 100644
index dc6a4dc..0000000
--- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/DelegateInjectionTarget.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi.internal;
-
-import java.util.Set;
-import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.inject.spi.InjectionPoint;
-import javax.enterprise.inject.spi.InjectionTarget;
-
-/**
- * A helper class for creating delegate implementations of {@link InjectionTarget}
- */
-public abstract class DelegateInjectionTarget implements InjectionTarget {
-    private final InjectionTarget delegate;
-
-    public DelegateInjectionTarget(InjectionTarget<Object> delegate) {
-        this.delegate = delegate;
-    }
-
-    @Override
-    public void dispose(Object instance) {
-        delegate.dispose(instance);
-    }
-
-    @Override
-    public Set<InjectionPoint> getInjectionPoints() {
-        return delegate.getInjectionPoints();
-    }
-
-    @Override
-    public void inject(Object instance, CreationalContext ctx) {
-        delegate.inject(instance, ctx);
-    }
-
-    @Override
-    public void postConstruct(Object instance) {
-        delegate.postConstruct(instance);
-    }
-
-    @Override
-    public void preDestroy(Object instance) {
-        delegate.preDestroy(instance);
-    }
-
-    @Override
-    public Object produce(CreationalContext creationalContext) {
-        return delegate.produce(creationalContext);
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/resources/META-INF/LICENSE.txt
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/resources/META-INF/LICENSE.txt b/components/camel-cdi/src/main/resources/META-INF/LICENSE.txt
deleted file mode 100644
index 6b0b127..0000000
--- a/components/camel-cdi/src/main/resources/META-INF/LICENSE.txt
+++ /dev/null
@@ -1,203 +0,0 @@
-
-                                 Apache License
-                           Version 2.0, January 2004
-                        http://www.apache.org/licenses/
-
-   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-   1. Definitions.
-
-      "License" shall mean the terms and conditions for use, reproduction,
-      and distribution as defined by Sections 1 through 9 of this document.
-
-      "Licensor" shall mean the copyright owner or entity authorized by
-      the copyright owner that is granting the License.
-
-      "Legal Entity" shall mean the union of the acting entity and all
-      other entities that control, are controlled by, or are under common
-      control with that entity. For the purposes of this definition,
-      "control" means (i) the power, direct or indirect, to cause the
-      direction or management of such entity, whether by contract or
-      otherwise, or (ii) ownership of fifty percent (50%) or more of the
-      outstanding shares, or (iii) beneficial ownership of such entity.
-
-      "You" (or "Your") shall mean an individual or Legal Entity
-      exercising permissions granted by this License.
-
-      "Source" form shall mean the preferred form for making modifications,
-      including but not limited to software source code, documentation
-      source, and configuration files.
-
-      "Object" form shall mean any form resulting from mechanical
-      transformation or translation of a Source form, including but
-      not limited to compiled object code, generated documentation,
-      and conversions to other media types.
-
-      "Work" shall mean the work of authorship, whether in Source or
-      Object form, made available under the License, as indicated by a
-      copyright notice that is included in or attached to the work
-      (an example is provided in the Appendix below).
-
-      "Derivative Works" shall mean any work, whether in Source or Object
-      form, that is based on (or derived from) the Work and for which the
-      editorial revisions, annotations, elaborations, or other modifications
-      represent, as a whole, an original work of authorship. For the purposes
-      of this License, Derivative Works shall not include works that remain
-      separable from, or merely link (or bind by name) to the interfaces of,
-      the Work and Derivative Works thereof.
-
-      "Contribution" shall mean any work of authorship, including
-      the original version of the Work and any modifications or additions
-      to that Work or Derivative Works thereof, that is intentionally
-      submitted to Licensor for inclusion in the Work by the copyright owner
-      or by an individual or Legal Entity authorized to submit on behalf of
-      the copyright owner. For the purposes of this definition, "submitted"
-      means any form of electronic, verbal, or written communication sent
-      to the Licensor or its representatives, including but not limited to
-      communication on electronic mailing lists, source code control systems,
-      and issue tracking systems that are managed by, or on behalf of, the
-      Licensor for the purpose of discussing and improving the Work, but
-      excluding communication that is conspicuously marked or otherwise
-      designated in writing by the copyright owner as "Not a Contribution."
-
-      "Contributor" shall mean Licensor and any individual or Legal Entity
-      on behalf of whom a Contribution has been received by Licensor and
-      subsequently incorporated within the Work.
-
-   2. Grant of Copyright License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      copyright license to reproduce, prepare Derivative Works of,
-      publicly display, publicly perform, sublicense, and distribute the
-      Work and such Derivative Works in Source or Object form.
-
-   3. Grant of Patent License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      (except as stated in this section) patent license to make, have made,
-      use, offer to sell, sell, import, and otherwise transfer the Work,
-      where such license applies only to those patent claims licensable
-      by such Contributor that are necessarily infringed by their
-      Contribution(s) alone or by combination of their Contribution(s)
-      with the Work to which such Contribution(s) was submitted. If You
-      institute patent litigation against any entity (including a
-      cross-claim or counterclaim in a lawsuit) alleging that the Work
-      or a Contribution incorporated within the Work constitutes direct
-      or contributory patent infringement, then any patent licenses
-      granted to You under this License for that Work shall terminate
-      as of the date such litigation is filed.
-
-   4. Redistribution. You may reproduce and distribute copies of the
-      Work or Derivative Works thereof in any medium, with or without
-      modifications, and in Source or Object form, provided that You
-      meet the following conditions:
-
-      (a) You must give any other recipients of the Work or
-          Derivative Works a copy of this License; and
-
-      (b) You must cause any modified files to carry prominent notices
-          stating that You changed the files; and
-
-      (c) You must retain, in the Source form of any Derivative Works
-          that You distribute, all copyright, patent, trademark, and
-          attribution notices from the Source form of the Work,
-          excluding those notices that do not pertain to any part of
-          the Derivative Works; and
-
-      (d) If the Work includes a "NOTICE" text file as part of its
-          distribution, then any Derivative Works that You distribute must
-          include a readable copy of the attribution notices contained
-          within such NOTICE file, excluding those notices that do not
-          pertain to any part of the Derivative Works, in at least one
-          of the following places: within a NOTICE text file distributed
-          as part of the Derivative Works; within the Source form or
-          documentation, if provided along with the Derivative Works; or,
-          within a display generated by the Derivative Works, if and
-          wherever such third-party notices normally appear. The contents
-          of the NOTICE file are for informational purposes only and
-          do not modify the License. You may add Your own attribution
-          notices within Derivative Works that You distribute, alongside
-          or as an addendum to the NOTICE text from the Work, provided
-          that such additional attribution notices cannot be construed
-          as modifying the License.
-
-      You may add Your own copyright statement to Your modifications and
-      may provide additional or different license terms and conditions
-      for use, reproduction, or distribution of Your modifications, or
-      for any such Derivative Works as a whole, provided Your use,
-      reproduction, and distribution of the Work otherwise complies with
-      the conditions stated in this License.
-
-   5. Submission of Contributions. Unless You explicitly state otherwise,
-      any Contribution intentionally submitted for inclusion in the Work
-      by You to the Licensor shall be under the terms and conditions of
-      this License, without any additional terms or conditions.
-      Notwithstanding the above, nothing herein shall supersede or modify
-      the terms of any separate license agreement you may have executed
-      with Licensor regarding such Contributions.
-
-   6. Trademarks. This License does not grant permission to use the trade
-      names, trademarks, service marks, or product names of the Licensor,
-      except as required for reasonable and customary use in describing the
-      origin of the Work and reproducing the content of the NOTICE file.
-
-   7. Disclaimer of Warranty. Unless required by applicable law or
-      agreed to in writing, Licensor provides the Work (and each
-      Contributor provides its Contributions) on an "AS IS" BASIS,
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-      implied, including, without limitation, any warranties or conditions
-      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
-      PARTICULAR PURPOSE. You are solely responsible for determining the
-      appropriateness of using or redistributing the Work and assume any
-      risks associated with Your exercise of permissions under this License.
-
-   8. Limitation of Liability. In no event and under no legal theory,
-      whether in tort (including negligence), contract, or otherwise,
-      unless required by applicable law (such as deliberate and grossly
-      negligent acts) or agreed to in writing, shall any Contributor be
-      liable to You for damages, including any direct, indirect, special,
-      incidental, or consequential damages of any character arising as a
-      result of this License or out of the use or inability to use the
-      Work (including but not limited to damages for loss of goodwill,
-      work stoppage, computer failure or malfunction, or any and all
-      other commercial damages or losses), even if such Contributor
-      has been advised of the possibility of such damages.
-
-   9. Accepting Warranty or Additional Liability. While redistributing
-      the Work or Derivative Works thereof, You may choose to offer,
-      and charge a fee for, acceptance of support, warranty, indemnity,
-      or other liability obligations and/or rights consistent with this
-      License. However, in accepting such obligations, You may act only
-      on Your own behalf and on Your sole responsibility, not on behalf
-      of any other Contributor, and only if You agree to indemnify,
-      defend, and hold each Contributor harmless for any liability
-      incurred by, or claims asserted against, such Contributor by reason
-      of your accepting any such warranty or additional liability.
-
-   END OF TERMS AND CONDITIONS
-
-   APPENDIX: How to apply the Apache License to your work.
-
-      To apply the Apache License to your work, attach the following
-      boilerplate notice, with the fields enclosed by brackets "[]"
-      replaced with your own identifying information. (Don't include
-      the brackets!)  The text should be enclosed in the appropriate
-      comment syntax for the file format. We also recommend that a
-      file or class name and description of purpose be included on the
-      same "printed page" as the copyright notice for easier
-      identification within third-party archives.
-
-   Copyright [yyyy] [name of copyright owner]
-
-   Licensed 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.
-

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/resources/META-INF/NOTICE.txt
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/resources/META-INF/NOTICE.txt b/components/camel-cdi/src/main/resources/META-INF/NOTICE.txt
deleted file mode 100644
index 2e215bf..0000000
--- a/components/camel-cdi/src/main/resources/META-INF/NOTICE.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-   =========================================================================
-   ==  NOTICE file corresponding to the section 4 d of                    ==
-   ==  the Apache License, Version 2.0,                                   ==
-   ==  in this case for the Apache Camel distribution.                    ==
-   =========================================================================
-
-   This product includes software developed by
-   The Apache Software Foundation (http://www.apache.org/).
-
-   Please read the different LICENSE files present in the licenses directory of
-   this distribution.

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/resources/META-INF/beans.xml b/components/camel-cdi/src/main/resources/META-INF/beans.xml
index 112d56d..dd78a5d 100644
--- a/components/camel-cdi/src/main/resources/META-INF/beans.xml
+++ b/components/camel-cdi/src/main/resources/META-INF/beans.xml
@@ -1,18 +1,24 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
-  Licensed to the Apache Software Foundation (ASF) under one or more
-  contributor license agreements.  See the NOTICE file distributed with
-  this work for additional information regarding copyright ownership.
-  The ASF licenses this file to You under the Apache License, Version 2.0
-  (the "License"); you may not use this file except in compliance with
-  the License.  You may obtain a copy of the License at
+    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
+    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.
+    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.
 -->
-<beans/>
\ No newline at end of file
+<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
+                           http://xmlns.jcp.org/xml/ns/javaee/beans_1_0.xsd"
+       version="1.0" bean-discovery-mode="all">
+       
+</beans>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension b/components/camel-cdi/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
index fecef7b..7f78ef9 100644
--- a/components/camel-cdi/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
+++ b/components/camel-cdi/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
@@ -14,4 +14,5 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-org.apache.camel.cdi.internal.CamelExtension
\ No newline at end of file
+
+org.apache.camel.cdi.CdiCamelExtension
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/CamelContextAwareTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/CamelContextAwareTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/CamelContextAwareTest.java
deleted file mode 100644
index 79716c3..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/CamelContextAwareTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi;
-
-import javax.inject.Inject;
-
-import org.apache.camel.cdi.support.ContextAwareBean;
-import org.junit.Test;
-
-/**
- * Test context awareness.
- */
-public class CamelContextAwareTest extends CdiContextTestSupport {
-
-    @Inject
-    private ContextAwareBean bean;
-
-    @Test
-    public void shouldInjectCamelContextToBean() throws InterruptedException {
-        assertNotNull(bean.getCamelContext());
-        assertSame(context, bean.getCamelContext());
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/CamelEndpointInjectTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/CamelEndpointInjectTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/CamelEndpointInjectTest.java
deleted file mode 100644
index 9884b5c..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/CamelEndpointInjectTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi;
-
-import javax.inject.Inject;
-
-import org.apache.camel.Endpoint;
-import org.apache.camel.cdi.support.CamelEndpointInjectedBean;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.Test;
-
-/**
- * Test endpoint injection using vanilla camel annotations without the use of @Inject
- */
-public class CamelEndpointInjectTest extends CdiTestSupport {
-
-    @Inject
-    private CamelEndpointInjectedBean bean;
-
-    @Test
-    public void shouldInjectEndpoint() {
-        assertNotNull(bean);
-        Endpoint endpoint = bean.getEndpoint();
-        assertNotNull("Could not find injected endpoint!", endpoint);
-        assertEquals("endpoint URI", "direct://inject", endpoint.getEndpointUri());
-
-        MockEndpoint mockEndpoint = bean.getMockEndpoint();
-        assertNotNull("Could not find injected mock endpoint!", mockEndpoint);
-        assertEquals("mock endpoint URI", "mock://result", mockEndpoint.getEndpointUri());
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/CamelExtensionTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/CamelExtensionTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/CamelExtensionTest.java
deleted file mode 100644
index f7a83fc..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/CamelExtensionTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi;
-
-import javax.inject.Inject;
-
-import org.apache.camel.CamelContext;
-import org.junit.Test;
-
-/**
- * Test camel extension.
- */
-public class CamelExtensionTest extends CdiTestSupport {
-
-    @Inject
-    private CamelContext context;
-
-    @Test
-    public void shouldBeStartedByTestFramework() {
-        assertTrue(context.getStatus().isStarted());
-        assertFalse(context.getStatus().isStopped());
-        assertFalse(context.getStatus().isStopping());
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/CdiContextTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/CdiContextTestSupport.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/CdiContextTestSupport.java
deleted file mode 100644
index c82530b..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/CdiContextTestSupport.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi;
-
-import java.util.logging.LogManager;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.cdi.internal.CamelExtension;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.apache.deltaspike.cdise.api.CdiContainer;
-import org.apache.deltaspike.cdise.api.CdiContainerLoader;
-import org.apache.deltaspike.core.api.provider.BeanProvider;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-
-/**
- * Base class for cdi tests.
- */
-public abstract class CdiContextTestSupport extends CamelTestSupport {
-
-    private CdiContainer cdiContainer;
-
-    /**
-     * Reset configuration of java util logging and forward it to slf4j.
-     * 
-     * @throws Exception In case of failures.
-     */
-    @BeforeClass
-    public static void before() throws Exception {
-        LogManager.getLogManager().reset();
-        org.slf4j.bridge.SLF4JBridgeHandler.install();
-    }
-
-    @Before
-    public void setUp() throws Exception {
-        // set up CDI container before camel context start up
-        cdiContainer = CdiContainerLoader.getCdiContainer();
-        cdiContainer.boot();
-
-        // inject fields inside child classes
-        BeanProvider.injectFields(this);
-
-        super.setUp();
-    }
-
-    @After
-    public void tearDown() throws Exception {
-        super.tearDown();
-        cdiContainer.shutdown();
-    }
-
-    @Override
-    protected CamelContext createCamelContext() throws Exception {
-        return BeanProvider.getContextualReference(CdiCamelContext.class);
-    }
-
-    @Override
-    protected void applyCamelPostProcessor() throws Exception {
-        // lets perform any custom camel injection on the test case object
-        CamelExtension camelExtension = BeanProvider.getContextualReference(CamelExtension.class);
-        camelExtension.inject(this);
-    }
-}
-

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/CdiTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/CdiTestSupport.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/CdiTestSupport.java
deleted file mode 100644
index 0a002ff..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/CdiTestSupport.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi;
-
-import java.util.logging.LogManager;
-
-import org.apache.camel.test.junit4.TestSupport;
-import org.apache.deltaspike.cdise.api.CdiContainer;
-import org.apache.deltaspike.cdise.api.CdiContainerLoader;
-import org.apache.deltaspike.core.api.provider.BeanProvider;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-
-/**
- * Base class for cdi tests.
- */
-public abstract class CdiTestSupport extends TestSupport {
-
-    private CdiContainer cdiContainer;
-
-    /**
-     * Reset configuration of java util logging and forward it to slf4j.
-     * 
-     * @throws Exception In case of failures.
-     */
-    @BeforeClass
-    public static void before() throws Exception {
-        LogManager.getLogManager().reset();
-        org.slf4j.bridge.SLF4JBridgeHandler.install();
-    }
-
-    @Before
-    public void setUp() throws Exception {
-        // set up CDI container before camel context start up
-        cdiContainer = CdiContainerLoader.getCdiContainer();
-        cdiContainer.boot();
-
-        BeanProvider.injectFields(this);
-    }
-
-    @After
-    public void tearDown() throws Exception {
-        cdiContainer.shutdown();
-    }
-
-}
-

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/ConsumeStubbedEndpointTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/ConsumeStubbedEndpointTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/ConsumeStubbedEndpointTest.java
deleted file mode 100644
index bee7627..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/ConsumeStubbedEndpointTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi;
-
-import javax.inject.Inject;
-
-import org.apache.camel.Consume;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.Test;
-
-/**
- * Tests sending & consuming to a stubbed out component called 'cheese' which is created
- * via the {@link org.apache.camel.cdi.support.CheeseComponentFactory} class
- */
-public class ConsumeStubbedEndpointTest extends CdiTestSupport {
-
-    @Inject @Mock
-    private MockEndpoint result;
-
-    @Inject @Uri("cheese:start")
-    private ProducerTemplate producer;
-
-    @Consume(uri = "cheese:start")
-    public void onStart(String body) {
-        producer.sendBody("mock:result", "Hello " + body + "!");
-    }
-
-    @Test
-    public void consumeAnnotation() throws Exception {
-        assertNotNull("Could not inject producer", producer);
-        assertNotNull("Could not inject mock endpoint", result);
-
-        result.expectedBodiesReceived("Hello world!");
-
-        producer.sendBody("world");
-
-        result.assertIsSatisfied();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/ConsumeTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/ConsumeTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/ConsumeTest.java
deleted file mode 100644
index ee78313..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/ConsumeTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi;
-
-import javax.inject.Inject;
-
-import org.apache.camel.Consume;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.Test;
-
-/**
- * Test consume annotation
- */
-public class ConsumeTest extends CdiTestSupport {
-
-    @Inject @Mock
-    private MockEndpoint result;
-
-    @Inject @Uri("seda:start")
-    private ProducerTemplate producer;
-
-    @Consume(uri = "seda:start")
-    public void onStart(String body) {
-        producer.sendBody("mock:result", "Hello " + body + "!");
-    }
-
-    @Test
-    public void consumeAnnotation() throws Exception {
-        assertNotNull("Could not inject producer", producer);
-        assertNotNull("Could not inject mock endpoint", result);
-
-        result.expectedBodiesReceived("Hello world!");
-
-        producer.sendBody("world");
-
-        result.assertIsSatisfied();
-    }
-
-}


[6/9] camel git commit: CAMEL-9201: Improved Camel CDI component

Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointDefinedUsingConfigPropertyTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointDefinedUsingConfigPropertyTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointDefinedUsingConfigPropertyTest.java
deleted file mode 100644
index d254ccf..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointDefinedUsingConfigPropertyTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi;
-
-import java.util.ArrayList;
-import java.util.List;
-import javax.inject.Inject;
-
-import org.apache.camel.EndpointInject;
-import org.apache.camel.Exchange;
-import org.apache.camel.Produce;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.cdi.store.Item;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.deltaspike.core.api.config.ConfigProperty;
-import org.junit.Test;
-
-public class EndpointDefinedUsingConfigPropertyTest extends CdiContextTestSupport {
-
-    @Inject @ConfigProperty(name = "directEndpoint")
-    String directInjectEndpoint;
-
-    @EndpointInject(uri = "mock:result")
-    MockEndpoint mockResultEndpoint;
-
-    @Produce(uri = "direct:inject")
-    ProducerTemplate myProducer;
-
-    @Test
-    public void beanShouldBeInjected() throws InterruptedException {
-        mockResultEndpoint.expectedMessageCount(1);
-        myProducer.sendBody("hello");
-
-        assertMockEndpointsSatisfied();
-
-        Exchange exchange = mockResultEndpoint.getExchanges().get(0);
-        List<?> results = exchange.getIn().getBody(List.class);
-        List<Item> expected = itemsExpected();
-        assertNotNull(results);
-        assertNotNull(expected);
-        assertEquals(expected.size(), results.size());
-        assertEquals(expected, results);
-    }
-
-    private List<Item> itemsExpected() {
-        List<Item> products = new ArrayList<Item>();
-        for (int i = 1; i < 10; i++) {
-            products.add(new Item("Item-" + i, 1500L * i));
-        }
-        return products;
-    }
-
-    @Override
-    protected RouteBuilder createRouteBuilder() throws Exception {
-        return new RouteBuilder() {
-            @Override
-            public void configure() throws Exception {
-                from(directInjectEndpoint)
-                    .bean("shoppingBean", "listAllProducts")
-                    .to(mockResultEndpoint);
-            }
-        };
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointInjectTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointInjectTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointInjectTest.java
deleted file mode 100644
index df83848..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointInjectTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi;
-
-import javax.inject.Inject;
-
-import org.apache.camel.Endpoint;
-import org.apache.camel.cdi.support.EndpointInjectedBean;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.Test;
-
-/**
- * Test endpoint injection
- */
-public class EndpointInjectTest extends CdiTestSupport {
-
-    @Inject
-    private EndpointInjectedBean bean;
-
-    @Test
-    public void shouldInjectEndpoint() {
-        assertNotNull(bean);
-        Endpoint endpoint = bean.getEndpoint();
-        assertNotNull("Could not find injected endpoint!", endpoint);
-        assertTrue("Endpoint should be a MockEndpoint but was " + endpoint, endpoint instanceof MockEndpoint);
-        assertEquals("Endpoint URI", "mock://blah", endpoint.getEndpointUri());
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointNamedInjectTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointNamedInjectTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointNamedInjectTest.java
deleted file mode 100644
index 30f73c4..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointNamedInjectTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi;
-
-import javax.inject.Inject;
-import javax.inject.Named;
-
-import org.apache.camel.Endpoint;
-import org.junit.Test;
-
-/**
- * Test endpoint injection by @Named
- */
-public class EndpointNamedInjectTest extends CdiTestSupport {
-
-    @Inject @Named("myNamedEndpoint")
-    private Endpoint endpoint;
-
-    @Test
-    public void shouldInjectEndpoint() {
-        assertNotNull("Could not find injected endpoint!", endpoint);
-        assertEquals("Endpoint URI", "mock:nameInjected", endpoint.getEndpointUri());
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointPropertyInjectTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointPropertyInjectTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointPropertyInjectTest.java
deleted file mode 100644
index 3e9a174..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointPropertyInjectTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi;
-
-import javax.inject.Inject;
-
-import org.apache.camel.Endpoint;
-import org.apache.camel.cdi.support.EndpointUriPropertyInjectedBean;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.Test;
-
-/**
- * Test endpoint injection using a dynamic property expression
- */
-public class EndpointPropertyInjectTest extends CdiTestSupport {
-
-    @Inject
-    private EndpointUriPropertyInjectedBean bean;
-
-    @Test
-    public void shouldInjectEndpointByProperty() {
-        assertNotNull(bean);
-        Endpoint endpoint = bean.getEndpoint();
-        assertNotNull("Could not find injected endpoint!", endpoint);
-        assertTrue("Endpoint should be a MockEndpoint but was " + endpoint, endpoint instanceof MockEndpoint);
-        assertEquals("Endpoint URI", "mock://injectedByProperty", endpoint.getEndpointUri());
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointUriInjectTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointUriInjectTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointUriInjectTest.java
deleted file mode 100644
index d4daead..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/EndpointUriInjectTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi;
-
-import javax.inject.Inject;
-
-import org.apache.camel.Endpoint;
-import org.apache.camel.cdi.support.EndpointUriInjectedBean;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.Test;
-
-/**
- * Test endpoint injection
- */
-public class EndpointUriInjectTest extends CdiTestSupport {
-
-    @Inject
-    private EndpointUriInjectedBean bean;
-
-    @Test
-    public void shouldInjectEndpoint() {
-        assertNotNull(bean);
-        Endpoint endpoint = bean.getEndpoint();
-        assertNotNull("Could not find injected endpoint!", endpoint);
-        assertTrue("Endpoint should be a MockEndpoint but was " + endpoint, endpoint instanceof MockEndpoint);
-        assertEquals("Endpoint URI", "mock://uriInjected", endpoint.getEndpointUri());
-
-        Endpoint endpoint2 = bean.getEndpoint2();
-        assertNotNull("Could not find injected endpoint2!", endpoint2);
-        assertEquals("Endpoint URI", "mock://anotherEndpoint", endpoint2.getEndpointUri());
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/InjectCamelAnnotationsTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/InjectCamelAnnotationsTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/InjectCamelAnnotationsTest.java
deleted file mode 100644
index 5d6bce7..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/InjectCamelAnnotationsTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.camel.Endpoint;
-import org.apache.camel.EndpointInject;
-import org.apache.camel.Exchange;
-import org.apache.camel.Produce;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.cdi.store.Item;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.Test;
-
-public class InjectCamelAnnotationsTest extends CdiContextTestSupport {
-
-    @EndpointInject(uri = "direct:inject")
-    Endpoint directInjectEndpoint;
-
-    @EndpointInject(uri = "mock:result")
-    MockEndpoint mockResultEndpoint;
-
-    @Produce(uri = "direct:inject")
-    ProducerTemplate myProducer;
-
-    @Test
-    public void beanShouldBeInjected() throws InterruptedException {
-        mockResultEndpoint.expectedMessageCount(1);
-        myProducer.sendBody("hello");
-
-        assertMockEndpointsSatisfied();
-
-        Exchange exchange = mockResultEndpoint.getExchanges().get(0);
-        List<?> results = exchange.getIn().getBody(List.class);
-        List<Item> expected = itemsExpected();
-        assertNotNull(results);
-        assertNotNull(expected);
-        assertEquals(expected.size(), results.size());
-        assertEquals(expected, results);
-    }
-
-    private List<Item> itemsExpected() {
-        List<Item> products = new ArrayList<Item>();
-        for (int i = 1; i < 10; i++) {
-            products.add(new Item("Item-" + i, 1500L * i));
-        }
-        return products;
-    }
-
-    @Override
-    protected RouteBuilder createRouteBuilder() throws Exception {
-        return new RouteBuilder() {
-            @Override
-            public void configure() throws Exception {
-                from(directInjectEndpoint)
-                    .bean("shoppingBean", "listAllProducts")
-                    .to(mockResultEndpoint);
-            }
-        };
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/MockEndpointInjectTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/MockEndpointInjectTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/MockEndpointInjectTest.java
deleted file mode 100644
index f2af675..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/MockEndpointInjectTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi;
-
-import javax.inject.Inject;
-
-import org.apache.camel.cdi.support.MockEndpointInjectedBean;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.Test;
-
-/**
- * Test mock endpoint injection
- */
-public class MockEndpointInjectTest extends CdiTestSupport {
-
-    @Inject
-    private MockEndpointInjectedBean bean;
-
-    @Test
-    public void shouldInjectMockEndpoint() {
-        assertNotNull(bean);
-        MockEndpoint foo = bean.getFoo();
-        MockEndpoint bar = bean.getBar();
-        assertNotNull("Could not find injected foo endpoint!", foo);
-        assertNotNull("Could not find injected bar endpoint!", bar);
-
-        assertEquals("foo URI", "mock://foo", foo.getEndpointUri());
-        assertEquals("bar URI", "mock://something", bar.getEndpointUri());
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/ProduceInjectTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/ProduceInjectTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/ProduceInjectTest.java
deleted file mode 100644
index 1d56233..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/ProduceInjectTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi;
-
-import javax.inject.Inject;
-
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.cdi.support.ProduceInjectedBean;
-import org.junit.Test;
-
-/**
- * Test endpoint injection
- */
-public class ProduceInjectTest extends CdiTestSupport {
-
-    @Inject
-    private ProduceInjectedBean bean;
-
-    @Test
-    public void shouldInjectEndpoint() {
-        assertNotNull(bean);
-        ProducerTemplate producer = bean.getProducer();
-        assertNotNull("Could not find injected producer!", producer);
-        assertEquals("producer default URI", "mock://foo", producer.getDefaultEndpoint().getEndpointUri());
-
-        ProducerTemplate producer2 = bean.getProducer2();
-        assertNotNull("Could not find injected producer2!", producer2);
-        assertEquals("producer2 default URI", "mock://bar", producer2.getDefaultEndpoint().getEndpointUri());
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/RegistryLookupAndInjectorTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/RegistryLookupAndInjectorTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/RegistryLookupAndInjectorTest.java
deleted file mode 100644
index 34844e7..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/RegistryLookupAndInjectorTest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.cdi.store.Item;
-import org.apache.camel.cdi.store.ShoppingBean;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.Test;
-
-public class RegistryLookupAndInjectorTest extends CdiContextTestSupport {
-
-    private MockEndpoint resultEndpoint;
-
-    @Override
-    public void setUp() throws Exception {
-        super.setUp();
-
-        resultEndpoint = getMockEndpoint("mock:result");
-    }
-
-    @Test
-    public void shouldLookupBeanByName() throws InterruptedException {
-        resultEndpoint.expectedMessageCount(1);
-        template.sendBody("direct:injectByName", "hello");
-
-        assertMockEndpointsSatisfied();
-
-        Exchange exchange = resultEndpoint.getExchanges().get(0);
-        List<?> results = exchange.getIn().getBody(List.class);
-        List<Item> expected = itemsExpected();
-        assertNotNull(results);
-        assertNotNull(expected);
-        assertEquals(expected.size(), results.size());
-        assertEquals(expected, results);
-    }
-
-    @Test
-    public void shouldLookupBeanByTypeAndInjectFields() throws InterruptedException {
-        resultEndpoint.expectedMessageCount(1);
-        template.sendBody("direct:injectByType", "hello");
-
-        assertMockEndpointsSatisfied();
-
-        Exchange exchange = resultEndpoint.getExchanges().get(0);
-        List<?> results = exchange.getIn().getBody(List.class);
-        List<Item> expected = itemsExpected();
-        assertNotNull(results);
-        assertNotNull(expected);
-        assertEquals(expected.size(), results.size());
-        assertEquals(expected, results);
-    }
-
-    private List<Item> itemsExpected() {
-        List<Item> products = new ArrayList<Item>();
-        for (int i = 1; i < 10; i++) {
-            products.add(new Item("Item-" + i, 1500L * i));
-        }
-        return products;
-    }
-
-    @Override
-    protected RouteBuilder createRouteBuilder() throws Exception {
-        return new RouteBuilder() {
-            @Override
-            public void configure() throws Exception {
-                from("direct:injectByName")
-                    .bean("shoppingBean", "listAllProducts")
-                    .to("mock:result");
-                from("direct:injectByType")
-                    .bean(ShoppingBean.class, "listAllProducts")
-                     .to("mock:result");
-            }
-        };
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/XmlRoutesFromClassPathTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/XmlRoutesFromClassPathTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/XmlRoutesFromClassPathTest.java
deleted file mode 100644
index 1c6abfa..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/XmlRoutesFromClassPathTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi;
-
-import javax.enterprise.inject.Produces;
-import javax.inject.Inject;
-
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.model.RoutesDefinition;
-import org.junit.Test;
-
-/**
- * Checks we can load XML routes from the classpath and use then with CDI
- */
-public class XmlRoutesFromClassPathTest extends CdiTestSupport {
-    @Inject
-    @Mock
-    MockEndpoint results;
-
-    @Inject
-    @Uri("direct:start")
-    ProducerTemplate producer;
-
-    Object[] expectedBodies = {"body:1", "body:2"};
-    
-    @Produces
-    @ContextName
-    public RoutesDefinition createRoutes() throws Exception {
-        return RoutesXml.loadRoutesFromClasspath(new CdiCamelContext(), "routes.xml");
-    }
-    
-    @Test
-    public void xmlRoutesWorkOnClassPath() throws Exception {
-        assertNotNull("results not injected", results);
-        assertNotNull("producer not injected", producer);
-
-        results.expectedBodiesReceived(expectedBodies);
-
-        for (Object body : expectedBodies) {
-            producer.sendBody(body);
-        }
-
-        results.assertIsSatisfied();
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/XmlRoutesFromURLTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/XmlRoutesFromURLTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/XmlRoutesFromURLTest.java
deleted file mode 100644
index 7603aca..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/XmlRoutesFromURLTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi;
-
-import java.io.File;
-import java.net.URL;
-
-import org.apache.camel.model.RoutesDefinition;
-
-/**
- * Tests loading of routes as XML from a URL
- */
-public class XmlRoutesFromURLTest extends XmlRoutesFromClassPathTest {
-
-    @Override
-    public RoutesDefinition createRoutes() throws Exception {
-        String[] prefixes = {"camel-cdi", "components"};
-        String fileName = "src/test/resources/routes.xml";
-        File file = new File(fileName);
-        for (String prefix : prefixes) {
-            if (file.exists()) {
-                break;
-            }
-            file = new File(prefix, file.getPath());
-        }
-        assertTrue("The file " + file.getPath() + " does not exist", file.exists());
-        URL url = file.toURI().toURL();
-        return RoutesXml.loadRoutesFromURL(new CdiCamelContext(), url);
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/BeanInjectBean.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/BeanInjectBean.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/BeanInjectBean.java
new file mode 100644
index 0000000..8d3194d
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/BeanInjectBean.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.apache.camel.cdi.bean;
+
+import org.apache.camel.BeanInject;
+
+public class BeanInjectBean {
+
+    @BeanInject
+    private PropertyInjectBean injectBeanField;
+    
+    private PropertyInjectBean injectBeanMethod;
+
+    @BeanInject("beanName")
+    private NamedCamelBean injectBeanNamed;
+
+    public PropertyInjectBean getInjectBeanField() {
+        return injectBeanField;
+    }
+
+    @BeanInject
+    public void setInjectBeanMethod(PropertyInjectBean bean) {
+        injectBeanMethod = bean;
+    }
+
+    public PropertyInjectBean getInjectBeanMethod() {
+        return injectBeanMethod;
+    }
+
+    public NamedCamelBean getInjectBeanNamed() {
+        return injectBeanNamed;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/CamelContextAwareBean.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/CamelContextAwareBean.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/CamelContextAwareBean.java
new file mode 100644
index 0000000..bf74ae3
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/CamelContextAwareBean.java
@@ -0,0 +1,38 @@
+/**
+ * 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.cdi.bean;
+
+import javax.enterprise.context.ApplicationScoped;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.CamelContextAware;
+
+@ApplicationScoped
+public class CamelContextAwareBean implements CamelContextAware {
+
+    private CamelContext camelContext;
+
+    @Override
+    public void setCamelContext(CamelContext camelContext) {
+        this.camelContext = camelContext;
+    }
+
+    @Override
+    public CamelContext getCamelContext() {
+        return camelContext;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/CamelContextProducerMethod.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/CamelContextProducerMethod.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/CamelContextProducerMethod.java
new file mode 100644
index 0000000..3d24a39
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/CamelContextProducerMethod.java
@@ -0,0 +1,40 @@
+/**
+ * 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.cdi.bean;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.Produces;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.impl.DefaultCamelContext;
+
+public class CamelContextProducerMethod {
+
+    @Produces
+    @ApplicationScoped
+    CamelContext createAndStartContext() throws Exception {
+        DefaultCamelContext context = new DefaultCamelContext();
+        context.setName("camel-producer-method");
+        context.start();
+        return context;
+    }
+
+    void stopContext(@Disposes CamelContext context) throws Exception {
+        context.stop();
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/ConsumeMethodBean.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/ConsumeMethodBean.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/ConsumeMethodBean.java
new file mode 100644
index 0000000..728696b
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/ConsumeMethodBean.java
@@ -0,0 +1,38 @@
+/**
+ * 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.cdi.bean;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+
+import org.apache.camel.Body;
+import org.apache.camel.Consume;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.cdi.Uri;
+
+@ApplicationScoped
+public class ConsumeMethodBean {
+
+    @Inject
+    @Uri("mock:outbound")
+    private ProducerTemplate producer;
+
+    @Consume(uri = "seda:inbound")
+    public void consume(@Body String body) {
+        producer.sendBody(body);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/CustomLifecycleCamelContext.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/CustomLifecycleCamelContext.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/CustomLifecycleCamelContext.java
new file mode 100644
index 0000000..5603fc5
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/CustomLifecycleCamelContext.java
@@ -0,0 +1,52 @@
+/**
+ * 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.cdi.bean;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+
+import org.apache.camel.cdi.CdiCamelContext;
+import org.apache.camel.util.ObjectHelper;
+
+@ApplicationScoped
+public class CustomLifecycleCamelContext extends CdiCamelContext {
+
+    @Inject
+    CustomLifecycleCamelContext() {
+        setName("custom");
+    }
+
+    @PostConstruct
+    void postConstruct() {
+        try {
+            super.start();
+        } catch (Exception cause) {
+            throw ObjectHelper.wrapRuntimeCamelException(cause);
+        }
+    }
+
+    @PreDestroy
+    void preDestroy() {
+        try {
+            super.stop();
+        } catch (Exception cause) {
+            throw ObjectHelper.wrapRuntimeCamelException(cause);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/CustomPropertiesCamelContext.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/CustomPropertiesCamelContext.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/CustomPropertiesCamelContext.java
new file mode 100644
index 0000000..26ab25a
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/CustomPropertiesCamelContext.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.apache.camel.cdi.bean;
+
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.ApplicationScoped;
+
+import org.apache.camel.component.properties.PropertiesComponent;
+import org.apache.camel.impl.DefaultCamelContext;
+
+@ApplicationScoped
+public class CustomPropertiesCamelContext extends DefaultCamelContext {
+
+    @PostConstruct
+    void addPropertiesLocation() {
+        getComponent("properties", PropertiesComponent.class).setLocation("classpath:placeholder.properties");
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/DefaultCamelContextBean.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/DefaultCamelContextBean.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/DefaultCamelContextBean.java
new file mode 100644
index 0000000..a700d74
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/DefaultCamelContextBean.java
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cdi.bean;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Named;
+
+import org.apache.camel.impl.DefaultCamelContext;
+
+@Named("camel-cdi")
+@ApplicationScoped
+public class DefaultCamelContextBean extends DefaultCamelContext {
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EndpointInjectRoute.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EndpointInjectRoute.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EndpointInjectRoute.java
new file mode 100644
index 0000000..ee76bd0
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EndpointInjectRoute.java
@@ -0,0 +1,35 @@
+/**
+ * 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.cdi.bean;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.builder.RouteBuilder;
+
+public class EndpointInjectRoute extends RouteBuilder {
+
+    @EndpointInject(uri = "direct:inbound")
+    private Endpoint inbound;
+
+    @EndpointInject(uri = "mock:outbound")
+    private Endpoint outbound;
+    
+    @Override
+    public void configure() {
+        from(inbound).to(outbound);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EndpointInjectWrongContextRoute.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EndpointInjectWrongContextRoute.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EndpointInjectWrongContextRoute.java
new file mode 100644
index 0000000..d75cc10
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EndpointInjectWrongContextRoute.java
@@ -0,0 +1,36 @@
+/**
+ * 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.cdi.bean;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.builder.RouteBuilder;
+
+public class EndpointInjectWrongContextRoute extends RouteBuilder {
+
+    @EndpointInject(uri = "direct:inbound")
+    private Endpoint inbound;
+
+    // Wrong context name should lead to resolution exception
+    @EndpointInject(uri = "mock:outbound", context = "foo")
+    private Endpoint outbound;
+    
+    @Override
+    public void configure() {
+        from(inbound).to(outbound);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EventConsumingRoute.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EventConsumingRoute.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EventConsumingRoute.java
new file mode 100644
index 0000000..3978dda
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EventConsumingRoute.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.apache.camel.cdi.bean;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.CdiEventEndpoint;
+import org.apache.camel.cdi.pojo.EventPayload;
+import org.apache.camel.cdi.qualifier.BarQualifier;
+import org.apache.camel.cdi.qualifier.FooQualifier;
+
+@ApplicationScoped
+public class EventConsumingRoute extends RouteBuilder {
+
+    @Inject
+    private CdiEventEndpoint<Object> objectCdiEventEndpoint;
+
+    @Inject
+    private CdiEventEndpoint<String> stringCdiEventEndpoint;
+
+    @Inject
+    private CdiEventEndpoint<EventPayload<String>> stringPayloadCdiEventEndpoint;
+
+    @Inject
+    private CdiEventEndpoint<EventPayload<Integer>> integerPayloadCdiEventEndpoint;
+
+    @Inject
+    @FooQualifier
+    private CdiEventEndpoint<Long> fooQualifierCdiEventEndpoint;
+
+    @Inject
+    @BarQualifier
+    private CdiEventEndpoint<Long> barQualifierCdiEventEndpoint;
+
+    @Override
+    public void configure() {
+        from(objectCdiEventEndpoint).to("mock:consumeObject");
+
+        from(stringCdiEventEndpoint).to("mock:consumeString");
+
+        from(stringPayloadCdiEventEndpoint).to("mock:consumeStringPayload");
+
+        from(integerPayloadCdiEventEndpoint).to("mock:consumeIntegerPayload");
+
+        from(fooQualifierCdiEventEndpoint).to("mock:consumeFooQualifier");
+
+        from(barQualifierCdiEventEndpoint).to("mock:consumeBarQualifier");
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EventConsumingRouteCdi10.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EventConsumingRouteCdi10.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EventConsumingRouteCdi10.java
new file mode 100644
index 0000000..59bac31
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EventConsumingRouteCdi10.java
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cdi.bean;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.CdiEventEndpoint;
+import org.apache.camel.cdi.pojo.EventPayloadInteger;
+import org.apache.camel.cdi.pojo.EventPayloadString;
+import org.apache.camel.cdi.qualifier.BarQualifier;
+import org.apache.camel.cdi.qualifier.FooQualifier;
+
+@ApplicationScoped
+public class EventConsumingRouteCdi10 extends RouteBuilder {
+
+    @Inject
+    private CdiEventEndpoint<Object> objectCdiEventEndpoint;
+
+    @Inject
+    private CdiEventEndpoint<String> stringCdiEventEndpoint;
+
+    @Inject
+    private CdiEventEndpoint<EventPayloadString> stringPayloadCdiEventEndpoint;
+
+    @Inject
+    private CdiEventEndpoint<EventPayloadInteger> integerPayloadCdiEventEndpoint;
+
+    @Inject
+    @FooQualifier
+    private CdiEventEndpoint<Long> fooQualifierCdiEventEndpoint;
+
+    @Inject
+    @BarQualifier
+    private CdiEventEndpoint<Long> barQualifierCdiEventEndpoint;
+
+    @Override
+    public void configure() {
+        from(objectCdiEventEndpoint).to("mock:consumeObject");
+
+        from(stringCdiEventEndpoint).to("mock:consumeString");
+
+        from(stringPayloadCdiEventEndpoint).to("mock:consumeStringPayload");
+
+        from(integerPayloadCdiEventEndpoint).to("mock:consumeIntegerPayload");
+
+        from(fooQualifierCdiEventEndpoint).to("mock:consumeFooQualifier");
+
+        from(barQualifierCdiEventEndpoint).to("mock:consumeBarQualifier");
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EventProducingRoute.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EventProducingRoute.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EventProducingRoute.java
new file mode 100644
index 0000000..a662c4b
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EventProducingRoute.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.apache.camel.cdi.bean;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.CdiEventEndpoint;
+import org.apache.camel.cdi.pojo.EventPayload;
+import org.apache.camel.cdi.qualifier.BarQualifier;
+import org.apache.camel.cdi.qualifier.FooQualifier;
+
+@ApplicationScoped
+public class EventProducingRoute extends RouteBuilder {
+
+    @Inject
+    private CdiEventEndpoint<Object> objectCdiEventEndpoint;
+
+    @Inject
+    private CdiEventEndpoint<String> stringCdiEventEndpoint;
+
+    @Inject
+    private CdiEventEndpoint<EventPayload<String>> stringPayloadCdiEventEndpoint;
+
+    @Inject
+    private CdiEventEndpoint<EventPayload<Integer>> integerPayloadCdiEventEndpoint;
+
+    @Inject
+    @FooQualifier
+    private CdiEventEndpoint<Long> fooQualifierCdiEventEndpoint;
+
+    @Inject
+    @BarQualifier
+    private CdiEventEndpoint<Long> barQualifierCdiEventEndpoint;
+
+    @Override
+    public void configure() {
+        from("direct:produceObject").to(objectCdiEventEndpoint);
+
+        from("direct:produceString").to(stringCdiEventEndpoint);
+
+        from("direct:produceStringPayload").to(stringPayloadCdiEventEndpoint);
+
+        from("direct:produceIntegerPayload").to(integerPayloadCdiEventEndpoint);
+
+        from("direct:produceFooQualifier").to(fooQualifierCdiEventEndpoint);
+
+        from("direct:produceBarQualifier").to(barQualifierCdiEventEndpoint);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EventProducingRouteCdi10.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EventProducingRouteCdi10.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EventProducingRouteCdi10.java
new file mode 100644
index 0000000..b0b3031
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EventProducingRouteCdi10.java
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cdi.bean;
+
+import javax.enterprise.context.ApplicationScoped;
+
+import javax.inject.Inject;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.CdiEventEndpoint;
+import org.apache.camel.cdi.pojo.EventPayloadInteger;
+import org.apache.camel.cdi.pojo.EventPayloadString;
+import org.apache.camel.cdi.qualifier.BarQualifier;
+import org.apache.camel.cdi.qualifier.FooQualifier;
+
+@ApplicationScoped
+public class EventProducingRouteCdi10 extends RouteBuilder {
+
+    @Inject
+    private CdiEventEndpoint<Object> objectCdiEventEndpoint;
+
+    @Inject
+    private CdiEventEndpoint<String> stringCdiEventEndpoint;
+
+    @Inject
+    private CdiEventEndpoint<EventPayloadString> stringPayloadCdiEventEndpoint;
+
+    @Inject
+    private CdiEventEndpoint<EventPayloadInteger> integerPayloadCdiEventEndpoint;
+
+    @Inject
+    @FooQualifier
+    private CdiEventEndpoint<Long> fooQualifierCdiEventEndpoint;
+
+    @Inject
+    @BarQualifier
+    private CdiEventEndpoint<Long> barQualifierCdiEventEndpoint;
+
+    @Override
+    public void configure() {
+        from("direct:produceObject").to(objectCdiEventEndpoint);
+
+        from("direct:produceString").to(stringCdiEventEndpoint);
+
+        from("direct:produceStringPayload").to(stringPayloadCdiEventEndpoint);
+
+        from("direct:produceIntegerPayload").to(integerPayloadCdiEventEndpoint);
+
+        from("direct:produceFooQualifier").to(fooQualifierCdiEventEndpoint);
+
+        from("direct:produceBarQualifier").to(barQualifierCdiEventEndpoint);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextBean.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextBean.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextBean.java
new file mode 100644
index 0000000..22f5819
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextBean.java
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cdi.bean;
+
+import javax.enterprise.context.ApplicationScoped;
+
+import org.apache.camel.cdi.ContextName;
+import org.apache.camel.impl.DefaultCamelContext;
+
+@ApplicationScoped
+@ContextName("first")
+public class FirstCamelContextBean extends DefaultCamelContext {
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextEndpointInjectRoute.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextEndpointInjectRoute.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextEndpointInjectRoute.java
new file mode 100644
index 0000000..a85e8e5
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextEndpointInjectRoute.java
@@ -0,0 +1,34 @@
+/**
+ * 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.cdi.bean;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.ContextName;
+
+@ContextName("first")
+public class FirstCamelContextEndpointInjectRoute extends RouteBuilder {
+
+    @EndpointInject(uri = "direct:inbound", context = "first")
+    private Endpoint inbound;
+    
+    @Override
+    public void configure() {
+        from(inbound).setHeader("context").constant("first").to("mock:outbound");
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextEventConsumingRoute.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextEventConsumingRoute.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextEventConsumingRoute.java
new file mode 100644
index 0000000..8de6978
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextEventConsumingRoute.java
@@ -0,0 +1,38 @@
+/**
+ * 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.cdi.bean;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.CdiEventEndpoint;
+import org.apache.camel.cdi.ContextName;
+
+@ApplicationScoped
+@ContextName("first")
+public class FirstCamelContextEventConsumingRoute extends RouteBuilder {
+
+    @Inject
+    @ContextName("first")
+    private CdiEventEndpoint<String> stringCdiEventEndpoint;
+
+    @Override
+    public void configure() {
+        from(stringCdiEventEndpoint).to("mock:consumeString");
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextEventProducingRoute.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextEventProducingRoute.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextEventProducingRoute.java
new file mode 100644
index 0000000..b3aa140
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextEventProducingRoute.java
@@ -0,0 +1,38 @@
+/**
+ * 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.cdi.bean;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.CdiEventEndpoint;
+import org.apache.camel.cdi.ContextName;
+
+@ApplicationScoped
+@ContextName("first")
+public class FirstCamelContextEventProducingRoute extends RouteBuilder {
+
+    @Inject
+    @ContextName("first")
+    private CdiEventEndpoint<String> stringCdiEventEndpoint;
+
+    @Override
+    public void configure() {
+        from("direct:produceString").to(stringCdiEventEndpoint);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextProduceTemplateBean.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextProduceTemplateBean.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextProduceTemplateBean.java
new file mode 100644
index 0000000..85583bb
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextProduceTemplateBean.java
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cdi.bean;
+
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+
+public class FirstCamelContextProduceTemplateBean {
+
+    @Produce(uri = "mock:outbound", context = "first")
+    private ProducerTemplate producer;
+
+    public void sendToProducer(String body) {
+        producer.sendBody(body + "-first");
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextPropertyInjectBean.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextPropertyInjectBean.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextPropertyInjectBean.java
new file mode 100644
index 0000000..3ae6a22
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextPropertyInjectBean.java
@@ -0,0 +1,38 @@
+/**
+ * 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.cdi.bean;
+
+import java.util.Map;
+
+import org.apache.camel.Handler;
+import org.apache.camel.Headers;
+import org.apache.camel.PropertyInject;
+
+public class FirstCamelContextPropertyInjectBean {
+
+    @PropertyInject(value = "property", context = "first")
+    private String property;
+
+    @Handler
+    public void process(@Headers Map<String, Object> headers) {
+        headers.put("header", property);
+    }
+    
+    public String getProperty() {
+        return property;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextRoute.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextRoute.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextRoute.java
new file mode 100644
index 0000000..14ae3f6
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextRoute.java
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cdi.bean;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.ContextName;
+
+@ContextName("first")
+public class FirstCamelContextRoute extends RouteBuilder {
+
+    @Override
+    public void configure() {
+        from("direct:inbound").setHeader("context").constant("first").to("mock:outbound");
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstNamedCamelContextBean.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstNamedCamelContextBean.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstNamedCamelContextBean.java
new file mode 100644
index 0000000..254ade6
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstNamedCamelContextBean.java
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cdi.bean;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Named;
+
+import org.apache.camel.cdi.ContextName;
+import org.apache.camel.impl.DefaultCamelContext;
+
+@ApplicationScoped
+@Named("first")
+@ContextName("first")
+public class FirstNamedCamelContextBean extends DefaultCamelContext {
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstNamedCamelContextRoute.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstNamedCamelContextRoute.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstNamedCamelContextRoute.java
new file mode 100644
index 0000000..2db055f
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstNamedCamelContextRoute.java
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cdi.bean;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.ContextName;
+
+@ContextName("first")
+public class FirstNamedCamelContextRoute extends RouteBuilder {
+
+    @Override
+    public void configure() {
+        from("direct:in").transform(body().prepend("first-")).to("direct:out");
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/InjectedEndpointRoute.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/InjectedEndpointRoute.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/InjectedEndpointRoute.java
new file mode 100644
index 0000000..a0f742b
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/InjectedEndpointRoute.java
@@ -0,0 +1,35 @@
+/**
+ * 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.cdi.bean;
+
+import javax.inject.Inject;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.Uri;
+
+public class InjectedEndpointRoute extends RouteBuilder {
+
+    @Inject
+    @Uri("direct:inbound")
+    private Endpoint inbound;
+    
+    @Override
+    public void configure() {
+        from(inbound).to("mock:outbound");
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/InjectedTypeConverterRoute.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/InjectedTypeConverterRoute.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/InjectedTypeConverterRoute.java
new file mode 100644
index 0000000..c8d3ca5
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/InjectedTypeConverterRoute.java
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cdi.bean;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.pojo.TypeConverterOutput;
+
+public class InjectedTypeConverterRoute extends RouteBuilder {
+
+    @Override
+    public void configure() {
+        from("direct:inbound").convertBodyTo(TypeConverterOutput.class).to("mock:outbound");
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/ManualCamelRoute.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/ManualCamelRoute.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/ManualCamelRoute.java
new file mode 100644
index 0000000..4bdc130
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/ManualCamelRoute.java
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cdi.bean;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.qualifier.Manual;
+
+@Manual
+public class ManualCamelRoute extends RouteBuilder {
+
+    @Override
+    public void configure() {
+        from("direct:manual").routeId("manual").to("mock:manual");
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/ManualStartupCamelContext.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/ManualStartupCamelContext.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/ManualStartupCamelContext.java
new file mode 100644
index 0000000..005b96c
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/ManualStartupCamelContext.java
@@ -0,0 +1,37 @@
+/**
+ * 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.cdi.bean;
+
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+
+import org.apache.camel.impl.DefaultCamelContext;
+
+@ApplicationScoped
+public class ManualStartupCamelContext extends DefaultCamelContext {
+
+    @Inject
+    ManualStartupCamelContext() {
+        setName("manual-startup");
+    }
+
+    @PostConstruct
+    void postConstruct() {
+        setAutoStartup(false);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/MockAnnotationRoute.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/MockAnnotationRoute.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/MockAnnotationRoute.java
new file mode 100644
index 0000000..78aff0c
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/MockAnnotationRoute.java
@@ -0,0 +1,41 @@
+/**
+ * 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.cdi.bean;
+
+import javax.inject.Inject;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.Mock;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.component.mock.MockEndpoint;
+
+public class MockAnnotationRoute extends RouteBuilder {
+
+    @Inject
+    @Uri("direct:start")
+    private Endpoint directEP;
+
+    @Inject
+    @Mock("mock:result")
+    private MockEndpoint mockEP;
+
+    @Override
+    public void configure() {
+        from(directEP).to(mockEP);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/NamedCamelBean.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/NamedCamelBean.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/NamedCamelBean.java
new file mode 100644
index 0000000..3177dd9
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/NamedCamelBean.java
@@ -0,0 +1,27 @@
+/**
+ * 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.cdi.bean;
+
+import javax.inject.Named;
+
+@Named("beanName")
+public class NamedCamelBean {
+
+    public String processBody(String body) {
+        return body + "-processed";
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/ProduceTemplateBean.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/ProduceTemplateBean.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/ProduceTemplateBean.java
new file mode 100644
index 0000000..834f050
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/ProduceTemplateBean.java
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cdi.bean;
+
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+
+public class ProduceTemplateBean {
+
+    @Produce(uri = "mock:outbound")
+    private ProducerTemplate producer;
+
+    public void sendToProducer(String body) {
+        producer.sendBody(body + "-processed");
+    }
+}


[5/9] camel git commit: CAMEL-9201: Improved Camel CDI component

Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/PropertyEndpointRoute.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/PropertyEndpointRoute.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/PropertyEndpointRoute.java
new file mode 100644
index 0000000..6d5ee7d
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/PropertyEndpointRoute.java
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cdi.bean;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class PropertyEndpointRoute extends RouteBuilder {
+
+    @Override
+    public void configure() {
+        from("direct:{{from}}")
+            .routeId("route")
+            .setHeader("header").simple("properties:header.message")
+            .to("{{to}}");
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/PropertyInjectBean.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/PropertyInjectBean.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/PropertyInjectBean.java
new file mode 100644
index 0000000..e0cfbc4
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/PropertyInjectBean.java
@@ -0,0 +1,38 @@
+/**
+ * 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.cdi.bean;
+
+import java.util.Map;
+
+import org.apache.camel.Handler;
+import org.apache.camel.Headers;
+import org.apache.camel.PropertyInject;
+
+public class PropertyInjectBean {
+
+    @PropertyInject("property")
+    private String property;
+
+    @Handler
+    public void process(@Headers Map<String, Object> headers) {
+        headers.put("header", property);
+    }
+    
+    public String getProperty() {
+        return property;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/RecipientListMethodBean.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/RecipientListMethodBean.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/RecipientListMethodBean.java
new file mode 100644
index 0000000..3e54e6a
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/RecipientListMethodBean.java
@@ -0,0 +1,34 @@
+/**
+ * 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.cdi.bean;
+
+import java.util.Arrays;
+import java.util.List;
+import javax.enterprise.context.ApplicationScoped;
+
+import org.apache.camel.Consume;
+import org.apache.camel.RecipientList;
+
+@ApplicationScoped
+public class RecipientListMethodBean {
+
+    @RecipientList
+    @Consume(uri = "direct:inbound")
+    public List<String> route() {
+        return Arrays.asList("mock:outbound1", "mock:outbound2");
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondCamelContextBean.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondCamelContextBean.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondCamelContextBean.java
new file mode 100644
index 0000000..8f83e30
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondCamelContextBean.java
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cdi.bean;
+
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.ApplicationScoped;
+
+import org.apache.camel.cdi.ContextName;
+import org.apache.camel.impl.DefaultCamelContext;
+
+@ApplicationScoped
+@ContextName("second")
+public class SecondCamelContextBean extends DefaultCamelContext {
+
+    @PostConstruct
+    void postConstruct() {
+        setAutoStartup(false);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondCamelContextEndpointInjectRoute.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondCamelContextEndpointInjectRoute.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondCamelContextEndpointInjectRoute.java
new file mode 100644
index 0000000..9889786
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondCamelContextEndpointInjectRoute.java
@@ -0,0 +1,34 @@
+/**
+ * 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.cdi.bean;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.ContextName;
+
+@ContextName("second")
+public class SecondCamelContextEndpointInjectRoute extends RouteBuilder {
+
+    @EndpointInject(uri = "direct:inbound", context = "second")
+    private Endpoint inbound;
+    
+    @Override
+    public void configure() {
+        from(inbound).setHeader("context").constant("second").to("mock:outbound");
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondCamelContextEventConsumingRoute.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondCamelContextEventConsumingRoute.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondCamelContextEventConsumingRoute.java
new file mode 100644
index 0000000..45678a2
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondCamelContextEventConsumingRoute.java
@@ -0,0 +1,38 @@
+/**
+ * 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.cdi.bean;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.CdiEventEndpoint;
+import org.apache.camel.cdi.ContextName;
+
+@ApplicationScoped
+@ContextName("second")
+public class SecondCamelContextEventConsumingRoute extends RouteBuilder {
+
+    @Inject
+    @ContextName("second")
+    private CdiEventEndpoint<String> stringCdiEventEndpoint;
+
+    @Override
+    public void configure() {
+        from(stringCdiEventEndpoint).to("mock:consumeString");
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondCamelContextEventProducingRoute.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondCamelContextEventProducingRoute.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondCamelContextEventProducingRoute.java
new file mode 100644
index 0000000..d856d22
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondCamelContextEventProducingRoute.java
@@ -0,0 +1,38 @@
+/**
+ * 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.cdi.bean;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.CdiEventEndpoint;
+import org.apache.camel.cdi.ContextName;
+
+@ApplicationScoped
+@ContextName("second")
+public class SecondCamelContextEventProducingRoute extends RouteBuilder {
+
+    @Inject
+    @ContextName("second")
+    private CdiEventEndpoint<String> stringCdiEventEndpoint;
+
+    @Override
+    public void configure() {
+        from("direct:produceString").to(stringCdiEventEndpoint);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondCamelContextProduceTemplateBean.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondCamelContextProduceTemplateBean.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondCamelContextProduceTemplateBean.java
new file mode 100644
index 0000000..fe97114
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondCamelContextProduceTemplateBean.java
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cdi.bean;
+
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+
+public class SecondCamelContextProduceTemplateBean {
+
+    @Produce(uri = "mock:outbound", context = "second")
+    private ProducerTemplate producer;
+
+    public void sendToProducer(String body) {
+        producer.sendBody(body + "-second");
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondCamelContextPropertyInjectBean.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondCamelContextPropertyInjectBean.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondCamelContextPropertyInjectBean.java
new file mode 100644
index 0000000..b1006c4
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondCamelContextPropertyInjectBean.java
@@ -0,0 +1,38 @@
+/**
+ * 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.cdi.bean;
+
+import java.util.Map;
+
+import org.apache.camel.Handler;
+import org.apache.camel.Headers;
+import org.apache.camel.PropertyInject;
+
+public class SecondCamelContextPropertyInjectBean {
+
+    @PropertyInject(value = "property", context = "second")
+    private String property;
+
+    @Handler
+    public void process(@Headers Map<String, Object> headers) {
+        headers.put("header", property);
+    }
+    
+    public String getProperty() {
+        return property;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondNamedCamelContextBean.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondNamedCamelContextBean.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondNamedCamelContextBean.java
new file mode 100644
index 0000000..711e475
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondNamedCamelContextBean.java
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cdi.bean;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Named;
+
+import org.apache.camel.cdi.ContextName;
+import org.apache.camel.impl.DefaultCamelContext;
+
+@ApplicationScoped
+@Named("second")
+@ContextName("second")
+public class SecondNamedCamelContextBean extends DefaultCamelContext {
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondNamedCamelContextRoute.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondNamedCamelContextRoute.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondNamedCamelContextRoute.java
new file mode 100644
index 0000000..fd78a1e
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondNamedCamelContextRoute.java
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cdi.bean;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.ContextName;
+
+@ContextName("second")
+public class SecondNamedCamelContextRoute extends RouteBuilder {
+
+    @Override
+    public void configure() {
+        from("direct:in").transform(body().prepend("second-")).to("direct:out");
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SimpleCamelRoute.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SimpleCamelRoute.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SimpleCamelRoute.java
new file mode 100644
index 0000000..48de1e7
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SimpleCamelRoute.java
@@ -0,0 +1,40 @@
+/**
+ * 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.cdi.bean;
+
+import javax.inject.Inject;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.component.mock.MockEndpoint;
+
+public class SimpleCamelRoute extends RouteBuilder {
+
+    @Inject
+    @Uri("direct:start")
+    private Endpoint direct;
+
+    @Inject
+    @Uri("mock:result")
+    private MockEndpoint mock;
+
+    @Override
+    public void configure() {
+        from(direct).routeId("simple").to(mock);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/UriEndpointRoute.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/UriEndpointRoute.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/UriEndpointRoute.java
new file mode 100644
index 0000000..e75fe65
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/UriEndpointRoute.java
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cdi.bean;
+
+import javax.enterprise.context.ApplicationScoped;
+
+import org.apache.camel.builder.RouteBuilder;
+
+@ApplicationScoped
+public class UriEndpointRoute extends RouteBuilder {
+
+    @Override
+    public void configure() {
+        from("direct:inbound").routeId("uri-route").to("mock:outbound");
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/component/properties/PropertiesComponentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/component/properties/PropertiesComponentTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/component/properties/PropertiesComponentTest.java
deleted file mode 100644
index f6bd0b3..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/component/properties/PropertiesComponentTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi.component.properties;
-
-import org.apache.camel.cdi.CdiContextTestSupport;
-import org.junit.Test;
-
-/**
- * Verifies behavior of properties component in CDI environment.
- */
-public class PropertiesComponentTest extends CdiContextTestSupport {
-
-    @Test
-    public void shouldUseCdiProperties() throws Exception {
-        assertTrue(context.getComponent("properties") instanceof CdiPropertiesComponent);
-        String resolved = context.resolvePropertyPlaceholders("d{{directEndpoint}}b");
-
-        assertEquals("ddirect:injectb", resolved);
-        resolved = context.resolvePropertyPlaceholders("{{directEndpoint}}_{{directEndpoint}}");
-
-        assertEquals("direct:inject_direct:inject", resolved);
-    }
-
-    @Test
-    public void testNullArgument() throws Exception {
-        assertNull(context.resolvePropertyPlaceholders(null));
-    }
-
-    @Test
-    public void testTextWithNoPlaceholder() throws Exception {
-        assertEquals("IamAnonymous", context.resolvePropertyPlaceholders("IamAnonymous"));
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testUnknownNestedPlaceholder() throws Exception {
-        context.resolvePropertyPlaceholders("{{IamAnonymous}}");
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/converter/InjectedTypeConverter.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/converter/InjectedTypeConverter.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/converter/InjectedTypeConverter.java
new file mode 100644
index 0000000..ef0b245
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/converter/InjectedTypeConverter.java
@@ -0,0 +1,42 @@
+/**
+ * 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.cdi.converter;
+
+import javax.inject.Inject;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Converter;
+import org.apache.camel.cdi.pojo.TypeConverterInput;
+import org.apache.camel.cdi.pojo.TypeConverterOutput;
+
+@Converter
+public final class InjectedTypeConverter {
+
+    private final CamelContext context;
+    
+    @Inject
+    InjectedTypeConverter(CamelContext context) {
+        this.context = context;
+    }
+
+    @Converter
+    public TypeConverterOutput convert(TypeConverterInput input) throws Exception {
+        TypeConverterOutput output = new TypeConverterOutput();
+        output.setProperty(context.resolvePropertyPlaceholders(input.getProperty()));
+        return output;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/expression/ExchangeExpression.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/expression/ExchangeExpression.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/expression/ExchangeExpression.java
new file mode 100644
index 0000000..1576a74
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/expression/ExchangeExpression.java
@@ -0,0 +1,37 @@
+/**
+ * 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.cdi.expression;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Expression;
+import org.apache.camel.Predicate;
+import org.apache.camel.util.PredicateToExpressionAdapter;
+
+public final class ExchangeExpression {
+
+    private ExchangeExpression() {
+    }
+
+    public static Expression fromCamelContext(final String contextName) {
+        return new PredicateToExpressionAdapter(new Predicate() {
+            @Override
+            public boolean matches(Exchange exchange) {
+                return exchange.getContext().getName().equals(contextName);
+            }
+        });
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/pojo/EventPayload.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/pojo/EventPayload.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/pojo/EventPayload.java
new file mode 100644
index 0000000..8f7a6c8
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/pojo/EventPayload.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.apache.camel.cdi.pojo;
+
+public class EventPayload<T> {
+
+    private final T payload;
+
+    public EventPayload(T payload) {
+        this.payload = payload;
+    }
+
+    public T getPayload() {
+        return payload;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+        EventPayload that = (EventPayload) o;
+        return payload.equals(that.payload);
+    }
+
+    @Override
+    public int hashCode() {
+        return payload.hashCode();
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/pojo/EventPayloadInteger.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/pojo/EventPayloadInteger.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/pojo/EventPayloadInteger.java
new file mode 100644
index 0000000..7bf8ed8
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/pojo/EventPayloadInteger.java
@@ -0,0 +1,24 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cdi.pojo;
+
+public class EventPayloadInteger extends EventPayload<Integer> {
+
+    public EventPayloadInteger(Integer payload) {
+        super(payload);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/pojo/EventPayloadString.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/pojo/EventPayloadString.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/pojo/EventPayloadString.java
new file mode 100644
index 0000000..0b2160a
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/pojo/EventPayloadString.java
@@ -0,0 +1,24 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cdi.pojo;
+
+public class EventPayloadString extends EventPayload<String> {
+
+    public EventPayloadString(String payload) {
+        super(payload);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/pojo/TypeConverterInput.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/pojo/TypeConverterInput.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/pojo/TypeConverterInput.java
new file mode 100644
index 0000000..e176abe
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/pojo/TypeConverterInput.java
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cdi.pojo;
+
+public class TypeConverterInput {
+
+    private String property;
+
+    public String getProperty() {
+        return property;
+    }
+
+    public void setProperty(String property) {
+        this.property = property;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/pojo/TypeConverterOutput.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/pojo/TypeConverterOutput.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/pojo/TypeConverterOutput.java
new file mode 100644
index 0000000..2b95d54
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/pojo/TypeConverterOutput.java
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cdi.pojo;
+
+public class TypeConverterOutput {
+    
+    private String property;
+    
+    public String getProperty() {
+        return property;
+    }
+
+    public void setProperty(String property) {
+        this.property = property;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/qualifier/BarQualifier.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/qualifier/BarQualifier.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/qualifier/BarQualifier.java
new file mode 100644
index 0000000..606f75f
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/qualifier/BarQualifier.java
@@ -0,0 +1,38 @@
+/**
+ * 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.cdi.qualifier;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import javax.enterprise.util.AnnotationLiteral;
+import javax.inject.Qualifier;
+
+@Qualifier
+@Documented
+@Retention(RUNTIME)
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+public @interface BarQualifier {
+
+    final class Literal extends AnnotationLiteral<BarQualifier> implements BarQualifier {
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/qualifier/FooQualifier.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/qualifier/FooQualifier.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/qualifier/FooQualifier.java
new file mode 100644
index 0000000..f606124
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/qualifier/FooQualifier.java
@@ -0,0 +1,38 @@
+/**
+ * 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.cdi.qualifier;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import javax.enterprise.util.AnnotationLiteral;
+import javax.inject.Qualifier;
+
+@Qualifier
+@Documented
+@Retention(RUNTIME)
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+public @interface FooQualifier {
+
+    final class Literal extends AnnotationLiteral<FooQualifier> implements FooQualifier {
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/qualifier/Manual.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/qualifier/Manual.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/qualifier/Manual.java
new file mode 100644
index 0000000..0d5d4e7
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/qualifier/Manual.java
@@ -0,0 +1,34 @@
+/**
+ * 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.cdi.qualifier;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import javax.inject.Qualifier;
+
+@Qualifier
+@Documented
+@Retention(RUNTIME)
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+public @interface Manual {
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/rule/ExpectedDeploymentException.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/rule/ExpectedDeploymentException.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/rule/ExpectedDeploymentException.java
new file mode 100644
index 0000000..b6c2b5f
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/rule/ExpectedDeploymentException.java
@@ -0,0 +1,105 @@
+/**
+ * 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.cdi.rule;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hamcrest.CoreMatchers;
+import org.hamcrest.Matcher;
+import org.junit.rules.RuleChain;
+import org.junit.rules.TestRule;
+import org.junit.runner.Description;
+import org.junit.runners.model.Statement;
+
+import static org.hamcrest.CoreMatchers.allOf;
+import static org.hamcrest.CoreMatchers.anyOf;
+import static org.hamcrest.Matchers.hasItem;
+import static org.junit.Assert.assertThat;
+
+public final class ExpectedDeploymentException implements TestRule {
+
+    private final List<Matcher<Throwable>> exceptions = new ArrayList<>();
+
+    private final List<Matcher<String>> messages = new ArrayList<>();
+
+    private final LogVerifier log = new LogVerifier();
+
+    private final TestRule chain;
+
+    private ExpectedDeploymentException() {
+        chain = RuleChain
+            .outerRule(log)
+            .around(new TestRule() {
+                @Override
+                public Statement apply(final Statement base, Description description) {
+                    return new Statement() {
+                        @Override
+                        public void evaluate() throws Throwable {
+                            try {
+                                base.evaluate();
+                            } catch (Throwable exception) {
+                                assertThat(exception, allOf(pecs(exceptions)));
+                                try {
+                                    // OpenWebBeans logs the deployment exception details
+                                    // TODO: OpenWebBeans only log the root cause of exception thrown in producer methods
+                                    //assertThat(log.getMessages(), containsInRelativeOrder(pecs(messages)))
+                                    assertThat(log.getMessages(), anyOf(hasItems(messages)));
+                                } catch (AssertionError error) {
+                                    // Weld stores the deployment exception details in the exception message
+                                    assertThat(exception.getMessage(), allOf(pecs(messages)));
+                                }
+                            }
+                        }
+                    };
+                }
+            });
+    }
+
+    public static ExpectedDeploymentException none() {
+        return new ExpectedDeploymentException();
+    }
+
+    public ExpectedDeploymentException expect(Class<? extends Throwable> type) {
+        exceptions.add(CoreMatchers.<Throwable>instanceOf(type));
+        return this;
+    }
+
+    public ExpectedDeploymentException expectMessage(Matcher<String> matcher) {
+        messages.add(matcher);
+        return this;
+    }
+
+    @SuppressWarnings({"unchecked", "rawtypes"})
+    private <T> List<Matcher<? super T>> pecs(List<Matcher<T>> matchers) {
+        return new ArrayList<>((List) matchers);
+    }
+
+    private <T> Matcher<Iterable<? super T>>[] hasItems(List<Matcher<T>> matchers) {
+        @SuppressWarnings("unchecked")
+        Matcher<Iterable<? super T>>[] items = new Matcher[matchers.size()];
+        for (int i = 0; i < items.length; i++) {
+            items[i] = hasItem(matchers.get(i));
+        }
+        return items;
+    }
+
+    @Override
+    public Statement apply(Statement base, Description description) {
+        return chain.apply(base, description);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/rule/LogVerifier.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/rule/LogVerifier.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/rule/LogVerifier.java
new file mode 100644
index 0000000..804ae2c
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/rule/LogVerifier.java
@@ -0,0 +1,75 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cdi.rule;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.log4j.Appender;
+import org.apache.log4j.AppenderSkeleton;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.spi.LoggingEvent;
+import org.junit.rules.Verifier;
+import org.junit.runner.Description;
+import org.junit.runners.model.Statement;
+
+public class LogVerifier extends Verifier {
+
+    private final Appender appender;
+
+    private final List<String> messages = new ArrayList<>();
+
+    public LogVerifier() {
+        this.appender = new AppenderSkeleton() {
+            @Override
+            public void close() {
+            }
+
+            @Override
+            public boolean requiresLayout() {
+                return false;
+            }
+
+            @Override
+            protected void append(LoggingEvent event) {
+                messages.add(event.getRenderedMessage());
+            }
+        };
+    }
+
+    public List<String> getMessages() {
+        return Collections.unmodifiableList(messages);
+    }
+
+    @Override
+    public Statement apply(final Statement base, Description description) {
+        return new Statement() {
+            @Override
+            public void evaluate() throws Throwable {
+                LogManager.getRootLogger().addAppender(appender);
+                try {
+                    base.evaluate();
+                    verify();
+                } finally {
+                    LogManager.getRootLogger().removeAppender(appender);
+                    appender.close();
+                }
+            }
+        };
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/store/Item.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/store/Item.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/store/Item.java
deleted file mode 100644
index 1b82fa0..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/store/Item.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi.store;
-
-import java.io.Serializable;
-
-public class Item implements Serializable {
-    private static final long serialVersionUID = 1L;
-
-    private String name;
-    private long price;
-
-    public Item() {
-    }
-
-    public Item(String name, long price) {
-        this.name = name;
-        this.price = price;
-    }
-
-    /**
-     * @return the name
-     */
-    public String getName() {
-        return name;
-    }
-
-    /**
-     * @param name the name to set
-     */
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    /**
-     * @return the price
-     */
-    public long getPrice() {
-        return price;
-    }
-
-    /**
-     * @param price the price to set
-     */
-    public void setPrice(long price) {
-        this.price = price;
-    }
-
-    // Simple equals implementation
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
-            return false;
-        }
-
-        Item other = (Item)obj;
-        boolean nameMatch = name == null ? other.name == null : name.equals(other.name);
-        return nameMatch && price == other.price;
-    }
-
-    @Override
-    public int hashCode() {
-        return name.hashCode() * 997 + (int)price;
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/store/Products.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/store/Products.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/store/Products.java
deleted file mode 100644
index c91acdd..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/store/Products.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi.store;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-import javax.inject.Named;
-
-@Named
-public class Products implements Serializable {
-    private static final long serialVersionUID = 1L;
-
-    private List<Item> products = new ArrayList<Item>();
-
-    public Products() {
-    }
-
-    @PostConstruct
-    public void afterInit() {
-        for (int i = 1; i < 10; i++) {
-            Item item = new Item("Item-" + i, i * 1500L);
-            products.add(item);
-        }
-    }
-
-    @PreDestroy
-    public void preDestroy() {
-        products.clear();
-    }
-
-    /**
-     * @return the products
-     */
-    public List<Item> getProducts() {
-        return products;
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/store/ShoppingBean.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/store/ShoppingBean.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/store/ShoppingBean.java
deleted file mode 100644
index 0b0639a..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/store/ShoppingBean.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi.store;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-import javax.enterprise.inject.New;
-import javax.enterprise.inject.Produces;
-import javax.inject.Inject;
-import javax.inject.Named;
-
-@Named
-public class ShoppingBean implements Serializable {
-    private static final long serialVersionUID = 1L;
-
-    @Inject
-    private Products products;
-    private List<Item> items = new ArrayList<Item>();
-
-    public ShoppingBean() {
-    }
-
-    @Inject
-    public ShoppingBean(@New Item defaultItem) {
-        defaultItem.setName("Default Item");
-        defaultItem.setPrice(1000L);
-
-        items.add(defaultItem);
-    }
-
-    @Produces
-    @Named("selectedItems")
-    public List<Item> listSelectedItems() {
-        return this.items;
-    }
-
-    @Produces
-    @Named("allProducts")
-    public List<Item> listAllProducts() {
-        return this.products.getProducts();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/CamelEndpointInjectedBean.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/CamelEndpointInjectedBean.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/CamelEndpointInjectedBean.java
deleted file mode 100644
index a8c623a..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/CamelEndpointInjectedBean.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi.support;
-
-import org.apache.camel.Endpoint;
-import org.apache.camel.EndpointInject;
-import org.apache.camel.component.mock.MockEndpoint;
-
-public class CamelEndpointInjectedBean {
-
-    @EndpointInject(uri = "direct:inject")
-    Endpoint endpoint;
-
-    @EndpointInject(uri = "mock:result")
-    MockEndpoint mockEndpoint;
-
-    public Endpoint getEndpoint() {
-        return endpoint;
-    }
-
-    public MockEndpoint getMockEndpoint() {
-        return mockEndpoint;
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/CdiConfigFile.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/CdiConfigFile.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/CdiConfigFile.java
deleted file mode 100644
index e50418a..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/CdiConfigFile.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi.support;
-
-import org.apache.deltaspike.core.api.config.PropertyFileConfig;
-
-/**
- * Class which is used to retrieve camel properties files tp configure endpoints.
- * By default, it will check for the file META-INF/camel-properties
- */
-public class CdiConfigFile implements PropertyFileConfig {
-
-    private static final long serialVersionUID = 1L;
-
-    @Override
-    public String getPropertyFileName() {
-        return "META-INF/camel.properties";
-    }
-
-    @Override
-    public boolean isOptional() {
-        return false;
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/CheeseComponentFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/CheeseComponentFactory.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/CheeseComponentFactory.java
deleted file mode 100644
index 601d2e1..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/CheeseComponentFactory.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi.support;
-
-import javax.enterprise.inject.Produces;
-import javax.inject.Named;
-
-import org.apache.camel.Component;
-import org.apache.camel.component.stub.StubComponent;
-
-/**
- * Stubs out the "cheese" component for testing
- */
-public class CheeseComponentFactory {
-
-    @Produces
-    @Named("cheese")
-    public Component createCheeseComponent() {
-        return new StubComponent();
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/ContextAwareBean.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/ContextAwareBean.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/ContextAwareBean.java
deleted file mode 100644
index c56e707..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/ContextAwareBean.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi.support;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.CamelContextAware;
-
-/**
- * Simple POJO interested in getting camel context.
- */
-public class ContextAwareBean implements CamelContextAware {
-
-    private CamelContext camelContext;
-
-    @Override
-    public CamelContext getCamelContext() {
-        return camelContext;
-    }
-
-    @Override
-    public void setCamelContext(CamelContext camelContext) {
-        this.camelContext = camelContext;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/EndpointInjectedBean.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/EndpointInjectedBean.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/EndpointInjectedBean.java
deleted file mode 100644
index 7f73aed..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/EndpointInjectedBean.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi.support;
-
-import org.apache.camel.Endpoint;
-import org.apache.camel.EndpointInject;
-
-/**
- */
-public class EndpointInjectedBean {
-
-    @EndpointInject(uri = "mock:blah")
-    private Endpoint endpoint;
-
-    public Endpoint getEndpoint() {
-        return endpoint;
-    }
-
-    public void setEndpoint(Endpoint endpoint) {
-        this.endpoint = endpoint;
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/EndpointUriInjectedBean.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/EndpointUriInjectedBean.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/EndpointUriInjectedBean.java
deleted file mode 100644
index 4d98b55..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/EndpointUriInjectedBean.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi.support;
-
-import javax.inject.Inject;
-
-import org.apache.camel.Endpoint;
-import org.apache.camel.cdi.Uri;
-
-/**
- */
-public class EndpointUriInjectedBean {
-
-    @Inject @Uri("mock:uriInjected")
-    private Endpoint endpoint;
-
-    @Inject @Uri("mock:anotherEndpoint")
-    private Endpoint endpoint2;
-
-    public Endpoint getEndpoint() {
-        return endpoint;
-    }
-
-    public void setEndpoint(Endpoint endpoint) {
-        this.endpoint = endpoint;
-    }
-
-    public Endpoint getEndpoint2() {
-        return endpoint2;
-    }
-
-    public void setEndpoint2(Endpoint endpoint2) {
-        this.endpoint2 = endpoint2;
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/EndpointUriPropertyInjectedBean.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/EndpointUriPropertyInjectedBean.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/EndpointUriPropertyInjectedBean.java
deleted file mode 100644
index a52dbc7..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/EndpointUriPropertyInjectedBean.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi.support;
-
-import org.apache.camel.Endpoint;
-import org.apache.camel.EndpointInject;
-
-/**
- */
-public class EndpointUriPropertyInjectedBean {
-
-    @EndpointInject(property = "injectUri")
-    private Endpoint endpoint;
-
-    public Endpoint getEndpoint() {
-        return endpoint;
-    }
-
-    public void setEndpoint(Endpoint endpoint) {
-        this.endpoint = endpoint;
-    }
-
-    public String getInjectUri() {
-        return "mock:injectedByProperty";
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/MockEndpointInjectedBean.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/MockEndpointInjectedBean.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/MockEndpointInjectedBean.java
deleted file mode 100644
index 694c116..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/MockEndpointInjectedBean.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi.support;
-
-import javax.inject.Inject;
-
-import org.apache.camel.cdi.Mock;
-import org.apache.camel.component.mock.MockEndpoint;
-
-public class MockEndpointInjectedBean {
-
-    @Inject @Mock
-    private MockEndpoint foo;
-
-    @Inject @Mock("mock:something")
-    private MockEndpoint bar;
-
-    public MockEndpoint getBar() {
-        return bar;
-    }
-
-    public MockEndpoint getFoo() {
-        return foo;
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/NamedEndpointBean.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/NamedEndpointBean.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/NamedEndpointBean.java
deleted file mode 100644
index c3916ab..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/NamedEndpointBean.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi.support;
-
-import javax.enterprise.inject.Produces;
-import javax.inject.Named;
-
-import org.apache.camel.Endpoint;
-import org.apache.camel.component.mock.MockComponent;
-import org.apache.camel.component.mock.MockEndpoint;
-
-/**
- */
-public class NamedEndpointBean {
-    @Produces @Named("myNamedEndpoint")
-    public Endpoint createEndpoint() {
-        return new MockEndpoint("mock:nameInjected", new MockComponent());
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/ProduceInjectedBean.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/ProduceInjectedBean.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/ProduceInjectedBean.java
deleted file mode 100644
index 01ee579..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/ProduceInjectedBean.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi.support;
-
-import javax.inject.Inject;
-
-import org.apache.camel.Produce;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.cdi.Uri;
-
-public class ProduceInjectedBean {
-
-    @Produce(uri = "mock:foo")
-    private ProducerTemplate producer;
-
-    @Inject @Uri("mock:bar")
-    private ProducerTemplate producer2;
-
-    public ProducerTemplate getProducer() {
-        return producer;
-    }
-
-    public ProducerTemplate getProducer2() {
-        return producer2;
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/AdvisedMockEndpointProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/AdvisedMockEndpointProducerTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/AdvisedMockEndpointProducerTest.java
new file mode 100644
index 0000000..4f454e3
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/AdvisedMockEndpointProducerTest.java
@@ -0,0 +1,96 @@
+/**
+ * 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.cdi.test;
+
+import java.util.concurrent.TimeUnit;
+import javax.inject.Inject;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.bean.ManualStartupCamelContext;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.junit.InSequence;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+
+@RunWith(Arquillian.class)
+public class AdvisedMockEndpointProducerTest {
+
+    @Inject
+    @Uri("direct:inbound")
+    private ProducerTemplate inbound;
+
+    @Inject
+    @Uri("mock:outbound")
+    private MockEndpoint outbound;
+
+    @Inject
+    @Uri("mock:intercepted")
+    private MockEndpoint intercepted;
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test class
+            .addClass(ManualStartupCamelContext.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    @InSequence(1)
+    public void startCamelContext(CamelContext context) throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() {
+                interceptSendToEndpoint("mock:outbound")
+                    .skipSendToOriginalEndpoint()
+                    .log("Intercepting message [${body}] from mock endpoint")
+                    .to("mock:intercepted");
+
+                from("direct:inbound").to("mock:outbound");
+            }
+        });
+
+        context.startAllRoutes();
+    }
+
+    @Test
+    @InSequence(2)
+    public void sendMessageToInbound() throws InterruptedException {
+        outbound.expectedMessageCount(0);
+        intercepted.expectedMessageCount(1);
+        intercepted.expectedBodiesReceived("test");
+
+        inbound.sendBody("test");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, outbound, intercepted);
+    }
+}


[9/9] camel git commit: CAMEL-9201: Improved Camel CDI component

Posted by da...@apache.org.
CAMEL-9201: Improved Camel CDI component


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/0421c24d
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/0421c24d
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/0421c24d

Branch: refs/heads/master
Commit: 0421c24dfcf992f3296ed746469771e3800200e3
Parents: d3d75d2
Author: Antonin Stefanutti <an...@stefanutti.fr>
Authored: Mon Aug 3 17:54:34 2015 +0200
Committer: Antonin Stefanutti <an...@stefanutti.fr>
Committed: Fri Jan 15 14:04:26 2016 +0100

----------------------------------------------------------------------
 components/camel-cdi/pom.xml                    | 320 ++++++++++++++---
 .../org/apache/camel/cdi/AnnotatedDelegate.java |  85 +++++
 .../camel/cdi/AnnotatedMemberDelegate.java      |  48 +++
 .../camel/cdi/AnnotatedMethodDelegate.java      |  44 +++
 .../apache/camel/cdi/AnnotatedTypeDelegate.java |  59 ++++
 .../org/apache/camel/cdi/AnnotatedWrapper.java  |  84 +++++
 .../java/org/apache/camel/cdi/AnyLiteral.java   |  31 ++
 .../java/org/apache/camel/cdi/BeanDelegate.java |  92 +++++
 .../org/apache/camel/cdi/BeanManagerHelper.java |  58 ++++
 .../camel/cdi/CamelBeanInjectionTarget.java     |  47 +++
 .../camel/cdi/CamelContextDefaultProducer.java  |  57 ++++
 .../camel/cdi/CamelContextInjectionTarget.java  |  35 ++
 .../camel/cdi/CamelContextOsgiProducer.java     |  62 ++++
 .../apache/camel/cdi/CamelContextProducer.java  | 129 +++++++
 .../apache/camel/cdi/CdiBeanManagerHelper.java  |  73 ----
 .../org/apache/camel/cdi/CdiBeanRegistry.java   | 119 -------
 .../camel/cdi/CdiCamelBeanPostProcessor.java    | 120 +++++++
 .../org/apache/camel/cdi/CdiCamelContext.java   |  80 +----
 .../apache/camel/cdi/CdiCamelContextBean.java   | 120 +++++++
 .../camel/cdi/CdiCamelContextNameStrategy.java  |  45 +++
 .../apache/camel/cdi/CdiCamelEnvironment.java   |  66 ++++
 .../org/apache/camel/cdi/CdiCamelExtension.java | 328 ++++++++++++++++++
 .../org/apache/camel/cdi/CdiCamelFactory.java   | 211 ++++++++++++
 .../org/apache/camel/cdi/CdiCamelInjector.java  |  48 +++
 .../org/apache/camel/cdi/CdiCamelRegistry.java  |  98 ++++++
 .../org/apache/camel/cdi/CdiEventComponent.java |  53 +++
 .../org/apache/camel/cdi/CdiEventConsumer.java  |  71 ++++
 .../org/apache/camel/cdi/CdiEventEndpoint.java  | 127 +++++++
 .../org/apache/camel/cdi/CdiEventNotifier.java  |  47 +++
 .../org/apache/camel/cdi/CdiEventProducer.java  |  47 +++
 .../java/org/apache/camel/cdi/CdiInjector.java  |  62 ----
 .../java/org/apache/camel/cdi/CdiSpiHelper.java | 143 ++++++++
 .../camel/cdi/CdiTypeConverterLoader.java       |  33 ++
 .../java/org/apache/camel/cdi/ContextName.java  | 131 ++++---
 .../org/apache/camel/cdi/DefaultLiteral.java    |  31 ++
 .../camel/cdi/DelegateInjectionTarget.java      |  51 +++
 .../org/apache/camel/cdi/DelegateProducer.java  |  51 +++
 .../java/org/apache/camel/cdi/Excluded.java     |  40 +++
 .../camel/cdi/ForwardingObserverMethod.java     |  78 +++++
 .../main/java/org/apache/camel/cdi/Main.java    |  65 ++--
 .../main/java/org/apache/camel/cdi/Mock.java    |  14 +-
 .../java/org/apache/camel/cdi/RoutesXml.java    |   2 +-
 .../src/main/java/org/apache/camel/cdi/Uri.java |  43 +--
 .../main/java/org/apache/camel/cdi/Vetoed.java  |  32 ++
 .../properties/CdiPropertiesComponent.java      |  33 --
 .../properties/CdiPropertiesParser.java         |  47 ---
 .../apache/camel/cdi/internal/BeanAdapter.java  | 133 --------
 .../camel/cdi/internal/CamelContextBean.java    | 138 --------
 .../camel/cdi/internal/CamelContextConfig.java  |  89 -----
 .../camel/cdi/internal/CamelContextMap.java     |  82 -----
 .../camel/cdi/internal/CamelExtension.java      | 342 -------------------
 .../apache/camel/cdi/internal/CamelFactory.java |  86 -----
 .../cdi/internal/DelegateInjectionTarget.java   |  63 ----
 .../src/main/resources/META-INF/LICENSE.txt     | 203 -----------
 .../src/main/resources/META-INF/NOTICE.txt      |  11 -
 .../src/main/resources/META-INF/beans.xml       |  32 +-
 .../javax.enterprise.inject.spi.Extension       |   3 +-
 .../apache/camel/cdi/CamelContextAwareTest.java |  38 ---
 .../camel/cdi/CamelEndpointInjectTest.java      |  46 ---
 .../apache/camel/cdi/CamelExtensionTest.java    |  39 ---
 .../apache/camel/cdi/CdiContextTestSupport.java |  79 -----
 .../org/apache/camel/cdi/CdiTestSupport.java    |  62 ----
 .../camel/cdi/ConsumeStubbedEndpointTest.java   |  55 ---
 .../java/org/apache/camel/cdi/ConsumeTest.java  |  54 ---
 .../EndpointDefinedUsingConfigPropertyTest.java |  79 -----
 .../apache/camel/cdi/EndpointInjectTest.java    |  43 ---
 .../camel/cdi/EndpointNamedInjectTest.java      |  39 ---
 .../camel/cdi/EndpointPropertyInjectTest.java   |  43 ---
 .../apache/camel/cdi/EndpointUriInjectTest.java |  47 ---
 .../camel/cdi/InjectCamelAnnotationsTest.java   |  78 -----
 .../camel/cdi/MockEndpointInjectTest.java       |  45 ---
 .../org/apache/camel/cdi/ProduceInjectTest.java |  45 ---
 .../cdi/RegistryLookupAndInjectorTest.java      |  94 -----
 .../camel/cdi/XmlRoutesFromClassPathTest.java   |  60 ----
 .../apache/camel/cdi/XmlRoutesFromURLTest.java  |  44 ---
 .../apache/camel/cdi/bean/BeanInjectBean.java   |  47 +++
 .../camel/cdi/bean/CamelContextAwareBean.java   |  38 +++
 .../cdi/bean/CamelContextProducerMethod.java    |  40 +++
 .../camel/cdi/bean/ConsumeMethodBean.java       |  38 +++
 .../cdi/bean/CustomLifecycleCamelContext.java   |  52 +++
 .../cdi/bean/CustomPropertiesCamelContext.java  |  32 ++
 .../camel/cdi/bean/DefaultCamelContextBean.java |  28 ++
 .../camel/cdi/bean/EndpointInjectRoute.java     |  35 ++
 .../bean/EndpointInjectWrongContextRoute.java   |  36 ++
 .../camel/cdi/bean/EventConsumingRoute.java     |  65 ++++
 .../cdi/bean/EventConsumingRouteCdi10.java      |  66 ++++
 .../camel/cdi/bean/EventProducingRoute.java     |  65 ++++
 .../cdi/bean/EventProducingRouteCdi10.java      |  66 ++++
 .../camel/cdi/bean/FirstCamelContextBean.java   |  28 ++
 .../FirstCamelContextEndpointInjectRoute.java   |  34 ++
 .../FirstCamelContextEventConsumingRoute.java   |  38 +++
 .../FirstCamelContextEventProducingRoute.java   |  38 +++
 .../FirstCamelContextProduceTemplateBean.java   |  30 ++
 .../FirstCamelContextPropertyInjectBean.java    |  38 +++
 .../camel/cdi/bean/FirstCamelContextRoute.java  |  29 ++
 .../cdi/bean/FirstNamedCamelContextBean.java    |  29 ++
 .../cdi/bean/FirstNamedCamelContextRoute.java   |  29 ++
 .../camel/cdi/bean/InjectedEndpointRoute.java   |  35 ++
 .../cdi/bean/InjectedTypeConverterRoute.java    |  28 ++
 .../apache/camel/cdi/bean/ManualCamelRoute.java |  29 ++
 .../cdi/bean/ManualStartupCamelContext.java     |  37 ++
 .../camel/cdi/bean/MockAnnotationRoute.java     |  41 +++
 .../apache/camel/cdi/bean/NamedCamelBean.java   |  27 ++
 .../camel/cdi/bean/ProduceTemplateBean.java     |  30 ++
 .../camel/cdi/bean/PropertyEndpointRoute.java   |  30 ++
 .../camel/cdi/bean/PropertyInjectBean.java      |  38 +++
 .../camel/cdi/bean/RecipientListMethodBean.java |  34 ++
 .../camel/cdi/bean/SecondCamelContextBean.java  |  33 ++
 .../SecondCamelContextEndpointInjectRoute.java  |  34 ++
 .../SecondCamelContextEventConsumingRoute.java  |  38 +++
 .../SecondCamelContextEventProducingRoute.java  |  38 +++
 .../SecondCamelContextProduceTemplateBean.java  |  30 ++
 .../SecondCamelContextPropertyInjectBean.java   |  38 +++
 .../cdi/bean/SecondNamedCamelContextBean.java   |  29 ++
 .../cdi/bean/SecondNamedCamelContextRoute.java  |  29 ++
 .../apache/camel/cdi/bean/SimpleCamelRoute.java |  40 +++
 .../apache/camel/cdi/bean/UriEndpointRoute.java |  30 ++
 .../properties/PropertiesComponentTest.java     |  53 ---
 .../cdi/converter/InjectedTypeConverter.java    |  42 +++
 .../cdi/expression/ExchangeExpression.java      |  37 ++
 .../org/apache/camel/cdi/pojo/EventPayload.java |  47 +++
 .../camel/cdi/pojo/EventPayloadInteger.java     |  24 ++
 .../camel/cdi/pojo/EventPayloadString.java      |  24 ++
 .../camel/cdi/pojo/TypeConverterInput.java      |  30 ++
 .../camel/cdi/pojo/TypeConverterOutput.java     |  30 ++
 .../camel/cdi/qualifier/BarQualifier.java       |  38 +++
 .../camel/cdi/qualifier/FooQualifier.java       |  38 +++
 .../org/apache/camel/cdi/qualifier/Manual.java  |  34 ++
 .../cdi/rule/ExpectedDeploymentException.java   | 105 ++++++
 .../org/apache/camel/cdi/rule/LogVerifier.java  |  75 ++++
 .../java/org/apache/camel/cdi/store/Item.java   |  85 -----
 .../org/apache/camel/cdi/store/Products.java    |  56 ---
 .../apache/camel/cdi/store/ShoppingBean.java    |  58 ----
 .../cdi/support/CamelEndpointInjectedBean.java  |  38 ---
 .../apache/camel/cdi/support/CdiConfigFile.java |  39 ---
 .../cdi/support/CheeseComponentFactory.java     |  35 --
 .../camel/cdi/support/ContextAwareBean.java     |  39 ---
 .../camel/cdi/support/EndpointInjectedBean.java |  36 --
 .../cdi/support/EndpointUriInjectedBean.java    |  49 ---
 .../EndpointUriPropertyInjectedBean.java        |  40 ---
 .../cdi/support/MockEndpointInjectedBean.java   |  39 ---
 .../camel/cdi/support/NamedEndpointBean.java    |  33 --
 .../camel/cdi/support/ProduceInjectedBean.java  |  40 ---
 .../test/AdvisedMockEndpointProducerTest.java   |  96 ++++++
 .../apache/camel/cdi/test/AdvisedRouteTest.java | 105 ++++++
 .../cdi/test/AmbiguousCamelContextTest.java     |  55 +++
 .../apache/camel/cdi/test/BeanInjectTest.java   |  88 +++++
 .../camel/cdi/test/CamelContextAwareTest.java   |  57 ++++
 .../cdi/test/CamelContextProducerFieldTest.java |  97 ++++++
 .../test/CamelContextProducerMethodTest.java    |  89 +++++
 .../camel/cdi/test/CamelEventEndpointTest.java  | 143 ++++++++
 .../camel/cdi/test/CamelEventNotifierTest.java  | 151 ++++++++
 .../camel/cdi/test/ConsumeMethodTest.java       |  69 ++++
 .../camel/cdi/test/ContextComponentTest.java    |  92 +++++
 .../camel/cdi/test/CustomCamelContextTest.java  |  90 +++++
 .../camel/cdi/test/DefaultCamelContextTest.java |  69 ++++
 .../camel/cdi/test/EndpointInjectTest.java      |  69 ++++
 .../camel/cdi/test/EventComponentTest.java      |  91 +++++
 .../camel/cdi/test/EventEndpointCdi12Test.java  | 277 +++++++++++++++
 .../camel/cdi/test/EventEndpointTest.java       | 282 +++++++++++++++
 .../camel/cdi/test/InjectedEndpointTest.java    |  68 ++++
 .../cdi/test/InjectedTypeConverterTest.java     | 103 ++++++
 .../camel/cdi/test/ManualCamelContextTest.java  | 117 +++++++
 .../apache/camel/cdi/test/MockEndpointTest.java |  84 +++++
 .../cdi/test/MultiCamelContextProducerTest.java | 168 +++++++++
 .../camel/cdi/test/MultiCamelContextTest.java   | 159 +++++++++
 .../test/MultiContextEndpointInjectTest.java    | 137 ++++++++
 .../cdi/test/MultiContextEventEndpointTest.java | 190 +++++++++++
 .../cdi/test/MultiContextEventNotifierTest.java | 300 ++++++++++++++++
 .../test/MultiContextProduceTemplateTest.java   | 157 +++++++++
 .../test/MultiContextPropertyInjectTest.java    | 193 +++++++++++
 .../camel/cdi/test/NamedCamelBeanTest.java      |  75 ++++
 .../camel/cdi/test/NamedCamelContextTest.java   | 114 +++++++
 .../camel/cdi/test/ProduceTemplateTest.java     |  76 +++++
 .../camel/cdi/test/PropertiesLocationTest.java  | 102 ++++++
 .../test/PropertiesMultipleLocationTest.java    |  55 +++
 .../camel/cdi/test/PropertyEndpointTest.java    |  88 +++++
 .../camel/cdi/test/PropertyInjectTest.java      | 101 ++++++
 .../cdi/test/QualifiedCamelContextTest.java     | 100 ++++++
 .../test/QualifiedMultiCamelContextTest.java    | 173 ++++++++++
 .../camel/cdi/test/RawEventEndpointTest.java    | 110 ++++++
 .../camel/cdi/test/RecipientListMethodTest.java |  77 +++++
 .../cdi/test/RouteDefinitionsFromXmlTest.java   |  78 +++++
 .../camel/cdi/test/UndefinedPropertyTest.java   |  83 +++++
 ...UnsatisfiedContextForEndpointInjectTest.java |  58 ++++
 .../cdi/test/UnstoppedCamelContextBeanTest.java |  87 +++++
 .../UnstoppedCamelContextProducerFieldTest.java |  82 +++++
 ...UnstoppedCamelContextProducerMethodTest.java |  88 +++++
 .../apache/camel/cdi/test/UriEndpointTest.java  |  69 ++++
 .../cdi/test/UriQualifierWithContextTest.java   |  90 +++++
 .../camel/cdi/test/UriWithWrongContextTest.java |  78 +++++
 .../src/test/resources/META-INF/beans.xml       |  18 -
 .../test/resources/META-INF/camel.properties    |   1 -
 .../camel-cdi/src/test/resources/bar.properties |  18 +
 .../camel-cdi/src/test/resources/foo.properties |  18 +
 .../src/test/resources/log4j.properties         |  23 +-
 .../src/test/resources/logging.properties       |  50 +++
 .../src/test/resources/placeholder.properties   |  18 +
 .../camel-cdi/src/test/resources/routes.xml     |  28 +-
 components/camel-sjms/pom.xml                   |   2 +-
 examples/camel-example-cdi/pom.xml              |  13 +-
 .../org/apache/camel/example/cdi/MyRoutes.java  |   4 +-
 parent/pom.xml                                  |  16 +-
 .../features/src/main/resources/features.xml    |   4 +-
 tests/camel-itest-cdi/pom.xml                   |  34 +-
 .../apache/camel/itest/cdi/CamelContextA.java   |  28 ++
 .../apache/camel/itest/cdi/CamelContextB.java   |  28 ++
 .../apache/camel/itest/cdi/CamelContextC.java   |  28 ++
 .../apache/camel/itest/cdi/CamelContextD.java   |  28 ++
 .../apache/camel/itest/cdi/RoutesContextA.java  |  22 +-
 .../apache/camel/itest/cdi/RoutesContextB.java  |  20 +-
 .../apache/camel/itest/cdi/RoutesContextC.java  |  17 +-
 .../apache/camel/itest/cdi/RoutesContextD.java  |  19 +-
 .../itest/cdi/properties/Camel1Config.java      |  38 ---
 .../itest/cdi/properties/Camel2Config.java      |  38 ---
 .../apache/camel/itest/cdi/CamelCdiTest.java    |  60 ++--
 .../itest/cdi/PropertiesConfigurationTest.java  |  75 ++++
 .../properties/PropertiesConfigurationTest.java |  69 ----
 .../META-INF/maven/archetype-metadata.xml       |   4 +-
 .../main/resources/archetype-resources/pom.xml  |  11 +-
 .../src/main/java/MyRoutes.java                 |   3 +-
 221 files changed, 11054 insertions(+), 3626 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-cdi/pom.xml b/components/camel-cdi/pom.xml
index 74b8635..648670d 100644
--- a/components/camel-cdi/pom.xml
+++ b/components/camel-cdi/pom.xml
@@ -26,136 +26,354 @@
 
   <artifactId>camel-cdi</artifactId>
   <packaging>bundle</packaging>
-  <name>Camel :: CDI</name>
-  <description>Camel Contexts and Dependency Injection (JSR-299) support</description>
+  <name>Camel :: CDI Component</name>
+  <description>Camel Contexts and Dependency Injection Support</description>
 
   <properties>
     <camel.osgi.import>
       !org.apache.camel.cdi.*,
       !org.apache.deltaspike.cdise.api.*,
-      org.apache.deltaspike.core.api.*;resolution:=optional,
       ${camel.osgi.import.defaults},
       *
     </camel.osgi.import>
     <camel.osgi.export.pkg>
-      org.apache.camel.cdi;${camel.osgi.version},
-      org.apache.camel.cdi.internal;${camel.osgi.version},
-      org.apache.camel.cdi.component.*;${camel.osgi.version}
+      org.apache.camel.cdi;${camel.osgi.version}
     </camel.osgi.export.pkg>
     <camel.osgi.provide.capability>
       org.ops4j.pax.cdi.extension; extension=camel-cdi-extension
     </camel.osgi.provide.capability>
-    <camel.osgi.require.capability>
-      osgi.extender;filter:="(osgi.extender=pax.cdi)",
-      org.ops4j.pax.cdi.extension;filter:="(extension=deltaspike-core-api)"
-    </camel.osgi.require.capability>
   </properties>
 
+  <dependencyManagement>
+    <dependencies>
+
+      <!-- test dependencies -->
+
+      <dependency>
+        <groupId>org.jboss.shrinkwrap.descriptors</groupId>
+        <artifactId>shrinkwrap-descriptors-bom</artifactId>
+        <version>${shrinkwrap-descriptors-version}</version>
+        <scope>import</scope>
+        <type>pom</type>
+      </dependency>
+
+      <dependency>
+        <groupId>org.jboss.arquillian</groupId>
+        <artifactId>arquillian-bom</artifactId>
+        <version>${arquillian-version}</version>
+        <scope>import</scope>
+        <type>pom</type>
+      </dependency>
+
+    </dependencies>
+  </dependencyManagement>
+
   <dependencies>
 
+    <!-- compile dependencies -->
+
     <dependency>
       <groupId>org.apache.camel</groupId>
       <artifactId>camel-core</artifactId>
     </dependency>
 
-    <!-- cdi api -->
-    <dependency>
-      <groupId>javax.enterprise</groupId>
-      <artifactId>cdi-api</artifactId>
-      <version>${cdi-api-version}</version>
-      <scope>provided</scope>
-    </dependency>
-
-    <!-- DeltaSpike -->
+    <!-- DeltaSpike is only used to provide Main support thus optional -->
     <dependency>
       <groupId>org.apache.deltaspike.core</groupId>
       <artifactId>deltaspike-core-api</artifactId>
       <version>${deltaspike-version}</version>
+      <optional>true</optional>
     </dependency>
 
     <dependency>
-      <groupId>org.apache.deltaspike.core</groupId>
-      <artifactId>deltaspike-core-impl</artifactId>
+      <groupId>org.apache.deltaspike.cdictrl</groupId>
+      <artifactId>deltaspike-cdictrl-api</artifactId>
       <version>${deltaspike-version}</version>
-      <scope>runtime</scope>
+      <optional>true</optional>
     </dependency>
 
-    <!-- only required for the Main -->
+    <!-- provided dependencies -->
+
     <dependency>
-      <groupId>org.apache.deltaspike.cdictrl</groupId>
-      <artifactId>deltaspike-cdictrl-api</artifactId>
-      <version>${deltaspike-version}</version>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core-osgi</artifactId>
+      <version>${project.version}</version>
+      <scope>provided</scope>
       <optional>true</optional>
     </dependency>
 
-    <!-- logging -->
     <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-log4j12</artifactId>
-      <scope>test</scope>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.core</artifactId>
+      <version>${osgi-version}</version>
+      <scope>provided</scope>
+      <optional>true</optional>
     </dependency>
+
+    <!-- test dependencies -->
+
     <dependency>
       <groupId>org.apache.camel</groupId>
-      <artifactId>camel-test</artifactId>
+      <artifactId>camel-context</artifactId>
+      <version>${project.version}</version>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.hamcrest</groupId>
+      <artifactId>hamcrest-library</artifactId>
+      <version>${hamcrest-version}</version>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
       <scope>test</scope>
     </dependency>
+
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+      <scope>test</scope>
+    </dependency>
+
     <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>jul-to-slf4j</artifactId>
       <version>${slf4j-version}</version>
       <scope>test</scope>
     </dependency>
-  </dependencies>
 
+    <dependency>
+      <groupId>org.jboss.arquillian.junit</groupId>
+      <artifactId>arquillian-junit-container</artifactId>
+      <version>${arquillian-version}</version>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.jboss.shrinkwrap.descriptors</groupId>
+      <artifactId>shrinkwrap-descriptors-depchain</artifactId>
+      <type>pom</type>
+      <scope>test</scope>
+    </dependency>
+
+  </dependencies>
 
   <profiles>
     <profile>
-      <id>owb</id>
+      <id>weld-1.0</id>
       <activation>
         <activeByDefault>true</activeByDefault>
       </activation>
+
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <configuration>
+              <excludes>
+                <exclude>**/*Cdi12Test.java</exclude>
+                <!-- Weld does not resolve observer method based on the runtime type of the event object, e.g. @Observe Long for a Long object fired with Event<Object> -->
+                <exclude>**/RawEventEndpointTest.java</exclude>
+              </excludes>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+
       <dependencies>
+
+        <!-- provided dependencies -->
+
         <dependency>
-          <groupId>org.apache.geronimo.specs</groupId>
-          <artifactId>geronimo-servlet_3.0_spec</artifactId>
+          <groupId>javax.enterprise</groupId>
+          <artifactId>cdi-api</artifactId>
+          <version>${cdi-api-1.0-version}</version>
+          <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+          <groupId>javax.el</groupId>
+          <artifactId>javax.el-api</artifactId>
+          <version>${javax.el-api-version}</version>
+          <scope>provided</scope>
+        </dependency>
+
+        <!-- test dependencies -->
+
+        <dependency>
+          <groupId>org.jboss.weld</groupId>
+          <artifactId>weld-core</artifactId>
+          <version>${weld1-version}</version>
+          <scope>test</scope>
+        </dependency>
+
+        <dependency>
+          <groupId>org.jboss.arquillian.container</groupId>
+          <artifactId>arquillian-weld-se-embedded-1.1</artifactId>
+          <version>${arquillian-weld-se-embedded-version}</version>
+          <scope>test</scope>
+        </dependency>
+
+      </dependencies>
+    </profile>
+
+    <profile>
+      <id>weld-1.2</id>
+
+      <dependencies>
+
+        <!-- provided dependencies -->
+
+        <dependency>
+          <groupId>javax.enterprise</groupId>
+          <artifactId>cdi-api</artifactId>
+          <version>${cdi-api-1.2-version}</version>
+          <scope>provided</scope>
+        </dependency>
+
+        <!-- test dependencies -->
+
+        <dependency>
+          <groupId>org.jboss.weld</groupId>
+          <artifactId>weld-core-impl</artifactId>
+          <version>${weld2-version}</version>
           <scope>test</scope>
         </dependency>
+
         <dependency>
-          <groupId>org.apache.deltaspike.cdictrl</groupId>
-          <artifactId>deltaspike-cdictrl-owb</artifactId>
-          <version>${deltaspike-version}</version>
+          <groupId>org.jboss.arquillian.container</groupId>
+          <artifactId>arquillian-weld-se-embedded-1.1</artifactId>
+          <version>${arquillian-weld-se-embedded-version}</version>
           <scope>test</scope>
         </dependency>
+
+      </dependencies>
+    </profile>
+
+    <profile>
+      <id>owb-1.0</id>
+
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <configuration>
+              <excludes>
+                <exclude>**/*Cdi12Test.java</exclude>
+                <!-- OWB does not call the InjectionTarget#preDestroy method -->
+                <exclude>**/UnstoppedCamelContext*Test.java</exclude>
+              </excludes>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+
+      <dependencies>
+
+        <!-- provided dependencies -->
+
+        <dependency>
+          <groupId>org.apache.geronimo.specs</groupId>
+          <artifactId>geronimo-jcdi_1.0_spec</artifactId>
+          <version>${geronimo-jcdi-1.0-spec-version}</version>
+          <scope>provided</scope>
+        </dependency>
+
         <dependency>
-          <groupId>org.apache.openwebbeans</groupId>
-          <artifactId>openwebbeans-impl</artifactId>
-          <version>${openwebbeans-version}</version>
+          <groupId>org.apache.geronimo.specs</groupId>
+          <artifactId>geronimo-atinject_1.0_spec</artifactId>
+          <version>${geronimo-atinject-1.0-spec-version}</version>
+          <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+          <groupId>org.apache.geronimo.specs</groupId>
+          <artifactId>geronimo-interceptor_1.1_spec</artifactId>
+          <version>${geronimo-interceptor-1.1-spec-version}</version>
+          <scope>provided</scope>
+        </dependency>
+
+        <!-- test dependencies -->
+
+        <dependency>
+          <groupId>org.apache.openwebbeans.arquillian</groupId>
+          <artifactId>owb-arquillian-standalone</artifactId>
+          <version>${openwebbeans1-version}</version>
           <scope>test</scope>
         </dependency>
+
         <dependency>
           <groupId>org.apache.openwebbeans</groupId>
-          <artifactId>openwebbeans-spi</artifactId>
-          <version>${openwebbeans-version}</version>
+          <artifactId>openwebbeans-impl</artifactId>
+          <version>${openwebbeans1-version}</version>
           <scope>test</scope>
         </dependency>
+
       </dependencies>
     </profile>
 
     <profile>
-      <id>weld2</id>
+      <id>owb-1.2</id>
+
       <dependencies>
+
+        <!-- provided dependencies -->
+
         <dependency>
-          <groupId>org.apache.deltaspike.cdictrl</groupId>
-          <artifactId>deltaspike-cdictrl-weld</artifactId>
-          <version>${deltaspike-version}</version>
-          <scope>test</scope>
+          <groupId>org.apache.geronimo.specs</groupId>
+          <artifactId>geronimo-jcdi_1.1_spec</artifactId>
+          <version>${geronimo-jcdi-1.1-spec-version}</version>
+          <scope>provided</scope>
         </dependency>
+
         <dependency>
-          <groupId>org.jboss.weld.se</groupId>
-          <artifactId>weld-se-core</artifactId>
-          <version>${weld2-version}</version>
+          <groupId>org.apache.geronimo.specs</groupId>
+          <artifactId>geronimo-atinject_1.0_spec</artifactId>
+          <version>${geronimo-atinject-1.0-spec-version}</version>
+          <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+          <groupId>org.apache.geronimo.specs</groupId>
+          <artifactId>geronimo-annotation_1.2_spec</artifactId>
+          <version>${geronimo-annotation-1.2-spec-version}</version>
+          <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+          <groupId>org.apache.geronimo.specs</groupId>
+          <artifactId>geronimo-interceptor_1.2_spec</artifactId>
+          <version>${geronimo-interceptor-1.2-spec-version}</version>
           <scope>provided</scope>
         </dependency>
+
+        <!-- test dependencies -->
+
+        <dependency>
+          <groupId>org.apache.openwebbeans.arquillian</groupId>
+          <artifactId>owb-arquillian-standalone</artifactId>
+          <version>${openwebbeans-version}</version>
+          <scope>test</scope>
+        </dependency>
+
+        <dependency>
+          <groupId>org.apache.openwebbeans</groupId>
+          <artifactId>openwebbeans-impl</artifactId>
+          <version>${openwebbeans-version}</version>
+          <scope>test</scope>
+        </dependency>
+
       </dependencies>
     </profile>
 

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/AnnotatedDelegate.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/AnnotatedDelegate.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/AnnotatedDelegate.java
new file mode 100644
index 0000000..ccd4989
--- /dev/null
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/AnnotatedDelegate.java
@@ -0,0 +1,85 @@
+/**
+ * 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.cdi;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.HashSet;
+import java.util.Set;
+import javax.enterprise.inject.spi.Annotated;
+
+class AnnotatedDelegate implements Annotated {
+
+    private final Annotated delegate;
+
+    private final Set<Annotation> annotations;
+
+    AnnotatedDelegate(Annotated delegate, Set<Annotation> annotations) {
+        this.delegate = delegate;
+        this.annotations = new HashSet<>(annotations);
+    }
+
+    AnnotatedDelegate(Annotated delegate) {
+        this.delegate = delegate;
+        this.annotations = delegate.getAnnotations();
+    }
+
+    @Override
+    public <T extends Annotation> T getAnnotation(Class<T> annotationType) {
+        for (Annotation annotation : annotations) {
+            if (annotation.annotationType().equals(annotationType)) {
+                return annotationType.cast(annotation);
+            }
+        }
+        return null;
+    }
+
+    @Override
+    public Set<Annotation> getAnnotations() {
+        return annotations;
+    }
+
+    @Override
+    public Type getBaseType() {
+        return delegate.getBaseType();
+    }
+
+    @Override
+    public Set<Type> getTypeClosure() {
+        return delegate.getTypeClosure();
+    }
+
+    @Override
+    public boolean isAnnotationPresent(Class<? extends Annotation> annotationType) {
+        return getAnnotation(annotationType) != null;
+    }
+
+    @Override
+    public String toString() {
+        return delegate.toString();
+    }
+    
+    @Override
+    public int hashCode() {
+        return delegate.hashCode();
+    }
+    
+    @Override
+    public boolean equals(Object object) {
+        return delegate.equals(object);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/AnnotatedMemberDelegate.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/AnnotatedMemberDelegate.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/AnnotatedMemberDelegate.java
new file mode 100644
index 0000000..d33732c
--- /dev/null
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/AnnotatedMemberDelegate.java
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cdi;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Member;
+import java.util.Set;
+import javax.enterprise.inject.spi.AnnotatedMember;
+import javax.enterprise.inject.spi.AnnotatedType;
+
+class AnnotatedMemberDelegate<T> extends AnnotatedDelegate implements AnnotatedMember<T> {
+
+    private final AnnotatedMember<T> delegate;
+    
+    AnnotatedMemberDelegate(AnnotatedMember<T> delegate, Set<Annotation> annotations) {
+        super(delegate, annotations);
+        this.delegate = delegate;
+    }
+
+    @Override
+    public AnnotatedType<T> getDeclaringType() {
+        return delegate.getDeclaringType();
+    }
+
+    @Override
+    public Member getJavaMember() {
+        return delegate.getJavaMember();
+    }
+
+    @Override
+    public boolean isStatic() {
+        return delegate.isStatic();
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/AnnotatedMethodDelegate.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/AnnotatedMethodDelegate.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/AnnotatedMethodDelegate.java
new file mode 100644
index 0000000..6e0b5df
--- /dev/null
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/AnnotatedMethodDelegate.java
@@ -0,0 +1,44 @@
+/**
+ * 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.cdi;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.List;
+import java.util.Set;
+import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.AnnotatedParameter;
+
+final class AnnotatedMethodDelegate<T> extends AnnotatedMemberDelegate<T> implements AnnotatedMethod<T> {
+    
+    private final AnnotatedMethod<T> delegate;
+    
+    AnnotatedMethodDelegate(AnnotatedMethod<T> delegate, Set<Annotation> annotations) {
+        super(delegate, annotations);
+        this.delegate = delegate;
+    }
+
+    @Override
+    public List<AnnotatedParameter<T>> getParameters() {
+        return delegate.getParameters();
+    }
+
+    @Override
+    public Method getJavaMember() {
+        return delegate.getJavaMember();
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/AnnotatedTypeDelegate.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/AnnotatedTypeDelegate.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/AnnotatedTypeDelegate.java
new file mode 100644
index 0000000..8d43662
--- /dev/null
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/AnnotatedTypeDelegate.java
@@ -0,0 +1,59 @@
+/**
+ * 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.cdi;
+
+import java.util.HashSet;
+import java.util.Set;
+import javax.enterprise.inject.spi.AnnotatedConstructor;
+import javax.enterprise.inject.spi.AnnotatedField;
+import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.AnnotatedType;
+
+final class AnnotatedTypeDelegate<T> extends AnnotatedDelegate implements AnnotatedType<T> {
+
+    private final Set<AnnotatedMethod<? super T>> methods;
+
+    private final AnnotatedType<T> delegate;
+
+    AnnotatedTypeDelegate(AnnotatedType<T> delegate, Set<AnnotatedMethod<? super T>> methods) {
+        super(delegate);
+        this.delegate = delegate;
+        this.methods = new HashSet<>(delegate.getMethods());
+        this.methods.removeAll(methods);
+        this.methods.addAll(methods);
+    }
+
+    @Override
+    public Set<AnnotatedConstructor<T>> getConstructors() {
+        return delegate.getConstructors();
+    }
+
+    @Override
+    public Set<AnnotatedField<? super T>> getFields() {
+        return delegate.getFields();
+    }
+
+    @Override
+    public Class<T> getJavaClass() {
+        return delegate.getJavaClass();
+    }
+
+    @Override
+    public Set<AnnotatedMethod<? super T>> getMethods() {
+        return methods;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/AnnotatedWrapper.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/AnnotatedWrapper.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/AnnotatedWrapper.java
new file mode 100644
index 0000000..013738a
--- /dev/null
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/AnnotatedWrapper.java
@@ -0,0 +1,84 @@
+/**
+ * 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.cdi;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Set;
+import javax.enterprise.inject.spi.Annotated;
+
+// This class is used as a work-around to OWB-1099
+final class AnnotatedWrapper implements Annotated {
+
+    private final Annotated delegate;
+
+    AnnotatedWrapper(Annotated delegate) {
+        this.delegate = delegate;
+    }
+
+    @Override
+    public Type getBaseType() {
+        return delegate.getBaseType();
+    }
+
+    @Override
+    public Set<Type> getTypeClosure() {
+        return delegate.getTypeClosure();
+    }
+
+    @Override
+    public <T extends Annotation> T getAnnotation(Class<T> annotationType) {
+        return delegate.getAnnotation(annotationType);
+    }
+
+    @Override
+    public Set<Annotation> getAnnotations() {
+        return delegate.getAnnotations();
+    }
+
+    @Override
+    public boolean isAnnotationPresent(Class<? extends Annotation> annotationType) {
+        return delegate.isAnnotationPresent(annotationType);
+    }
+
+    @Override
+    public boolean equals(Object object) {
+        if (this == object) {
+            return true;
+        }
+        if (object == null || getClass() != object.getClass()) {
+            return false;
+        }
+
+        AnnotatedWrapper that = (AnnotatedWrapper) object;
+
+        if (!getBaseType().equals(that.getBaseType())) {
+            return false;
+        } else if (!getTypeClosure().equals(that.getTypeClosure())) {
+            return false;
+        }
+        return getAnnotations().equals(that.getAnnotations());
+    }
+
+    @Override
+    public int hashCode() {
+        int result = getBaseType() != null ? getBaseType().hashCode() : 0;
+        result = 31 * result + (getTypeClosure() != null ? getTypeClosure().hashCode() : 0);
+        result = 31 * result + (getAnnotations() != null ? getAnnotations().hashCode() : 0);
+        return result;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/AnyLiteral.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/AnyLiteral.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/AnyLiteral.java
new file mode 100755
index 0000000..decff53
--- /dev/null
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/AnyLiteral.java
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cdi;
+
+import javax.enterprise.inject.Any;
+import javax.enterprise.util.AnnotationLiteral;
+
+@Vetoed
+final class AnyLiteral extends AnnotationLiteral<Any> implements Any {
+
+    static final Any INSTANCE = new AnyLiteral();
+
+    private static final long serialVersionUID = 1L;
+
+    private AnyLiteral() {
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/BeanDelegate.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/BeanDelegate.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/BeanDelegate.java
new file mode 100644
index 0000000..c1592cd
--- /dev/null
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/BeanDelegate.java
@@ -0,0 +1,92 @@
+/**
+ * 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.cdi;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Collections;
+import java.util.Set;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.InjectionPoint;
+
+final class BeanDelegate<T> implements Bean<T> {
+
+    private final Bean<T> delegate;
+
+    private final Set<Annotation> qualifiers;
+
+    BeanDelegate(Bean<T> delegate, Set<? extends Annotation> qualifiers) {
+        this.delegate = delegate;
+        this.qualifiers = Collections.unmodifiableSet(qualifiers);
+    }
+
+    @Override
+    public Set<Type> getTypes() {
+        return delegate.getTypes();
+    }
+
+    @Override
+    public Set<Annotation> getQualifiers() {
+        return qualifiers;
+    }
+
+    @Override
+    public Class<? extends Annotation> getScope() {
+        return delegate.getScope();
+    }
+
+    @Override
+    public String getName() {
+        return delegate.getName();
+    }
+
+    @Override
+    public Set<Class<? extends Annotation>> getStereotypes() {
+        return delegate.getStereotypes();
+    }
+
+    @Override
+    public boolean isAlternative() {
+        return delegate.isAlternative();
+    }
+
+    @Override
+    public Class<?> getBeanClass() {
+        return delegate.getBeanClass();
+    }
+
+    @Override
+    public Set<InjectionPoint> getInjectionPoints() {
+        return delegate.getInjectionPoints();
+    }
+
+    @Override
+    public boolean isNullable() {
+        return delegate.isNullable();
+    }
+
+    @Override
+    public T create(CreationalContext<T> creationalContext) {
+        return delegate.create(creationalContext);
+    }
+
+    @Override
+    public void destroy(T instance, CreationalContext<T> creationalContext) {
+        delegate.destroy(instance, creationalContext);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/BeanManagerHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/BeanManagerHelper.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/BeanManagerHelper.java
new file mode 100644
index 0000000..47118bf
--- /dev/null
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/BeanManagerHelper.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.apache.camel.cdi;
+
+import java.lang.annotation.Annotation;
+import java.util.HashSet;
+import java.util.Set;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+
+@Vetoed
+final class BeanManagerHelper {
+
+    private BeanManagerHelper() {
+    }
+
+    static <T> Set<T> getReferencesByType(BeanManager manager, Class<T> type, Annotation... qualifiers) {
+        Set<T> references = new HashSet<>();
+        for (Bean<?> bean : manager.getBeans(type, qualifiers)) {
+            references.add(getReference(manager, type, bean));
+        }
+        return references;
+    }
+
+    static <T> T getReferenceByName(BeanManager manager, String name, Class<T> type) {
+        Set<Bean<?>> beans = manager.getBeans(name);
+        if (beans == null || beans.isEmpty()) {
+            return null;
+        }
+        return getReference(manager, type, manager.resolve(beans));
+    }
+
+    static <T> T getReferenceByType(BeanManager manager, Class<T> type, Annotation... qualifiers) {
+        Set<Bean<?>> beans = manager.getBeans(type, qualifiers);
+        if (beans == null || beans.isEmpty()) {
+            return null;
+        }
+        return getReference(manager, type, manager.resolve(beans));
+    }
+
+    static <T> T getReference(BeanManager manager, Class<T> type, Bean<?> bean) {
+        return type.cast(manager.getReference(bean, type, manager.createCreationalContext(bean)));
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/CamelBeanInjectionTarget.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CamelBeanInjectionTarget.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CamelBeanInjectionTarget.java
new file mode 100644
index 0000000..9a78e61
--- /dev/null
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CamelBeanInjectionTarget.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.apache.camel.cdi;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.InjectionException;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.InjectionTarget;
+
+final class CamelBeanInjectionTarget<T> extends DelegateInjectionTarget<T> implements InjectionTarget<T> {
+
+    private final InjectionTarget<T> delegate;
+
+    private final CdiCamelBeanPostProcessor processor;
+
+    CamelBeanInjectionTarget(InjectionTarget<T> delegate, BeanManager manager) {
+        super(delegate);
+        this.delegate = delegate;
+        this.processor = new CdiCamelBeanPostProcessor(manager);
+    }
+
+    @Override
+    public void inject(T instance, CreationalContext<T> ctx) {
+        super.inject(instance, ctx);
+        try {
+            // TODO: see how to retrieve the bean name
+            processor.postProcessBeforeInitialization(instance, instance.getClass().getName());
+            processor.postProcessAfterInitialization(instance, instance.getClass().getName());
+        } catch (Exception cause) {
+            throw new InjectionException("Camel annotations post processing of [" + delegate + "] failed!", cause);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/CamelContextDefaultProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CamelContextDefaultProducer.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CamelContextDefaultProducer.java
new file mode 100644
index 0000000..4af15e7
--- /dev/null
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CamelContextDefaultProducer.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.apache.camel.cdi;
+
+import java.util.Collections;
+import java.util.Set;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.InjectionTarget;
+
+import org.apache.camel.impl.DefaultCamelContext;
+
+@Vetoed
+final class CamelContextDefaultProducer implements InjectionTarget<DefaultCamelContext> {
+
+    @Override
+    public DefaultCamelContext produce(CreationalContext<DefaultCamelContext> ctx) {
+        DefaultCamelContext context = new DefaultCamelContext();
+        context.setNameStrategy(new CdiCamelContextNameStrategy());
+        return context;
+    }
+
+    @Override
+    public void inject(DefaultCamelContext instance, CreationalContext<DefaultCamelContext> ctx) {
+    }
+
+    @Override
+    public void postConstruct(DefaultCamelContext instance) {
+    }
+
+    @Override
+    public void preDestroy(DefaultCamelContext instance) {
+    }
+
+    @Override
+    public void dispose(DefaultCamelContext instance) {
+    }
+
+    @Override
+    public Set<InjectionPoint> getInjectionPoints() {
+        return Collections.emptySet();
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/CamelContextInjectionTarget.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CamelContextInjectionTarget.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CamelContextInjectionTarget.java
new file mode 100644
index 0000000..4b84eed
--- /dev/null
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CamelContextInjectionTarget.java
@@ -0,0 +1,35 @@
+/**
+ * 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.cdi;
+
+import javax.enterprise.inject.spi.InjectionTarget;
+import javax.enterprise.inject.spi.Producer;
+
+import org.apache.camel.CamelContext;
+
+final class CamelContextInjectionTarget<T extends CamelContext> extends DelegateInjectionTarget<T> implements InjectionTarget<T> {
+
+    CamelContextInjectionTarget(InjectionTarget<T> target, Producer<T> producer) {
+        super(target, producer);
+    }
+
+    @Override
+    public void preDestroy(T instance) {
+        super.preDestroy(instance);
+        super.dispose(instance);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/CamelContextOsgiProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CamelContextOsgiProducer.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CamelContextOsgiProducer.java
new file mode 100644
index 0000000..d780255
--- /dev/null
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CamelContextOsgiProducer.java
@@ -0,0 +1,62 @@
+/**
+ * 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.cdi;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.InjectionException;
+import javax.enterprise.inject.spi.Producer;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.core.osgi.OsgiCamelContextHelper;
+import org.apache.camel.core.osgi.OsgiCamelContextPublisher;
+import org.apache.camel.core.osgi.utils.BundleContextUtils;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.DefaultCamelContextNameStrategy;
+import org.apache.camel.spi.CamelContextNameStrategy;
+import org.osgi.framework.BundleContext;
+
+final class CamelContextOsgiProducer<T extends CamelContext> extends DelegateProducer<T> {
+
+    CamelContextOsgiProducer(Producer<T> delegate) {
+        super(delegate);
+    }
+
+    @Override
+    public T produce(CreationalContext<T> ctx) {
+        T context = super.produce(ctx);
+
+        // Register the context in the OSGi registry
+        BundleContext bundle = BundleContextUtils.getBundleContext(getClass());
+        context.getManagementStrategy().addEventNotifier(new OsgiCamelContextPublisher(bundle));
+
+        if (!(context instanceof DefaultCamelContext)) {
+            // Fail fast for the time being to avoid side effects by some methods get declared on the CamelContext interface
+            throw new InjectionException("Camel CDI requires Camel context [" + context.getName() + "] to be a subtype of DefaultCamelContext");
+        }
+
+        DefaultCamelContext adapted = context.adapt(DefaultCamelContext.class);
+        adapted.setRegistry(OsgiCamelContextHelper.wrapRegistry(context, context.getRegistry(), bundle));
+        CamelContextNameStrategy strategy = context.getNameStrategy();
+        OsgiCamelContextHelper.osgiUpdate(adapted, bundle);
+        // FIXME: the above call should not override explicit strategies provided by the end user or should decorate them instead of overriding them completely
+        if (!(strategy instanceof DefaultCamelContextNameStrategy)) {
+            context.setNameStrategy(strategy);
+        }
+
+        return context;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/CamelContextProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CamelContextProducer.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CamelContextProducer.java
new file mode 100644
index 0000000..ebf80eb
--- /dev/null
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CamelContextProducer.java
@@ -0,0 +1,129 @@
+/**
+ * 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.cdi;
+
+import java.beans.Introspector;
+import java.lang.annotation.Annotation;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.InjectionException;
+import javax.enterprise.inject.spi.Annotated;
+import javax.enterprise.inject.spi.AnnotatedField;
+import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.Producer;
+import javax.inject.Named;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.DefaultCamelContextNameStrategy;
+import org.apache.camel.impl.ExplicitCamelContextNameStrategy;
+import org.apache.camel.spi.CamelContextNameStrategy;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+final class CamelContextProducer<T extends CamelContext> extends DelegateProducer<T> {
+
+    private final Logger logger = LoggerFactory.getLogger(getClass());
+
+    private final Annotated annotated;
+
+    private final BeanManager manager;
+
+    private final CdiCamelExtension extension;
+
+    CamelContextProducer(Producer<T> delegate, Annotated annotated, BeanManager manager, CdiCamelExtension extension) {
+        super(delegate);
+        this.annotated = annotated;
+        this.manager = manager;
+        this.extension = extension;
+    }
+
+    @Override
+    public T produce(CreationalContext<T> ctx) {
+        T context = super.produce(ctx);
+
+        // Do not override the name if it's been already set (in the bean constructor for example)
+        if (annotated != null && context.getNameStrategy() instanceof DefaultCamelContextNameStrategy) {
+            context.setNameStrategy(nameStrategy(annotated));
+        }
+
+        // Add bean registry and Camel injector
+        if (context instanceof DefaultCamelContext) {
+            DefaultCamelContext adapted = context.adapt(DefaultCamelContext.class);
+            adapted.setRegistry(new CdiCamelRegistry(manager));
+            adapted.setInjector(new CdiCamelInjector(context.getInjector(), manager));
+        } else {
+            // Fail fast for the time being to avoid side effects by the time these two methods get declared on the CamelContext interface
+            throw new InjectionException("Camel CDI requires Camel context [" + context.getName() + "] to be a subtype of DefaultCamelContext");
+        }
+
+        // Add event notifier if at least one observer is present
+        Set<Annotation> events = new HashSet<>(extension.getObserverEvents());
+        // Annotated must be wrapped because of OWB-1099
+        Collection<Annotation> qualifiers = annotated != null ? extension.getContextBean(new AnnotatedWrapper(annotated)).getQualifiers() : Arrays.asList(AnyLiteral.INSTANCE, DefaultLiteral.INSTANCE);
+        events.retainAll(qualifiers);
+        if (!events.isEmpty()) {
+            context.getManagementStrategy().addEventNotifier(new CdiEventNotifier(manager, qualifiers));
+        }
+
+        return context;
+    }
+
+    @Override
+    public void dispose(T context) {
+        super.dispose(context);
+
+        if (!context.getStatus().isStopped()) {
+            logger.info("Camel CDI is stopping Camel context [{}]", context.getName());
+            try {
+                context.stop();
+            } catch (Exception cause) {
+                throw ObjectHelper.wrapRuntimeCamelException(cause);
+            }
+        }
+    }
+
+    private static CamelContextNameStrategy nameStrategy(Annotated annotated) {
+        if (annotated.isAnnotationPresent(ContextName.class)) {
+            return new ExplicitCamelContextNameStrategy(annotated.getAnnotation(ContextName.class).value());
+        } else if (annotated.isAnnotationPresent(Named.class)) {
+            // TODO: support stereotype with empty @Named annotation
+            String name = annotated.getAnnotation(Named.class).value();
+            if (name.isEmpty()) {
+                if (annotated instanceof AnnotatedField) {
+                    name = ((AnnotatedField) annotated).getJavaMember().getName();
+                } else if (annotated instanceof AnnotatedMethod) {
+                    name = ((AnnotatedMethod) annotated).getJavaMember().getName();
+                    if (name.startsWith("get")) {
+                        name = Introspector.decapitalize(name.substring(3));
+                    }
+                } else {
+                    name = Introspector.decapitalize(CdiSpiHelper.getRawType(annotated.getBaseType()).getSimpleName());
+                }
+            }
+            return new ExplicitCamelContextNameStrategy(name);
+        } else {
+            // Use a specific naming strategy for Camel CDI as the default one increments the suffix for each CDI proxy created
+            return new CdiCamelContextNameStrategy();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiBeanManagerHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiBeanManagerHelper.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiBeanManagerHelper.java
deleted file mode 100644
index 91ecbd3..0000000
--- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiBeanManagerHelper.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi;
-
-import java.util.Set;
-import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.BeanManager;
-
-/**
- * To make looking up beans in CDI easier
- */
-public final class CdiBeanManagerHelper {
-
-    private CdiBeanManagerHelper() {
-    }
-
-    /**
-     * To lookup a bean by a type
-     */
-    public static <T> T lookupBeanByType(BeanManager beanManager, Class<T> type) {
-        Set<Bean<?>> beans = beanManager.getBeans(type);
-        if (!beans.isEmpty()) {
-            Bean<?> bean = beanManager.resolve(beans);
-            CreationalContext<?> creationalContext = beanManager.createCreationalContext(bean);
-            Object result = beanManager.getReference(bean, type, creationalContext);
-            if (result != null) {
-                return type.cast(result);
-            }
-        }
-
-        return null;
-    }
-
-    /**
-     * To lookup a bean by a name
-     */
-    public static Object lookupBeanByName(BeanManager beanManager, String name) {
-        return lookupBeanByNameAndType(beanManager, name, Object.class);
-    }
-
-    /**
-     * To lookup a bean by name and type
-     */
-    public static <T> T lookupBeanByNameAndType(BeanManager beanManager, String name, Class<T> type) {
-        Set<Bean<?>> beans = beanManager.getBeans(name);
-        if (!beans.isEmpty()) {
-            Bean<?> bean = beanManager.resolve(beans);
-            CreationalContext<?> creationalContext = beanManager.createCreationalContext(bean);
-            Object result = beanManager.getReference(bean, type, creationalContext);
-            if (result != null) {
-                return type.cast(result);
-            }
-        }
-
-        return null;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiBeanRegistry.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiBeanRegistry.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiBeanRegistry.java
deleted file mode 100644
index 4d131a9..0000000
--- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiBeanRegistry.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.cdi;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.BeanManager;
-
-import org.apache.camel.spi.Registry;
-import org.apache.camel.util.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * CdiBeanRegistry used by Camel to perform lookup into the CDI {@link javax.enterprise.inject.spi.BeanManager}.
- */
-public class CdiBeanRegistry implements Registry {
-    private static final Logger LOG = LoggerFactory.getLogger(CdiBeanRegistry.class);
-
-    private final BeanManager beanManager;
-
-    public CdiBeanRegistry(BeanManager beanManager) {
-        this.beanManager = beanManager;
-    }
-
-    @Override
-    public Object lookupByName(final String name) {
-        ObjectHelper.notEmpty(name, "name");
-        LOG.trace("Looking up bean with name {}", name);
-
-        return CdiBeanManagerHelper.lookupBeanByName(beanManager, name);
-    }
-
-    @Override
-    public <T> T lookupByNameAndType(final String name, final Class<T> type) {
-        ObjectHelper.notEmpty(name, "name");
-        ObjectHelper.notNull(type, "type");
-
-        LOG.trace("Looking up bean with name {} of type {}", name, type);
-        return CdiBeanManagerHelper.lookupBeanByNameAndType(beanManager, name, type);
-    }
-
-    @Override
-    public <T> Map<String, T> findByTypeWithName(final Class<T> type) {
-        ObjectHelper.notNull(type, "type");
-
-        LOG.trace("Lookups based of type {}", type);
-        Map<String, T> beans = new HashMap<String, T>();
-        Set<Bean<?>> definitions = beanManager.getBeans(type);
-
-        if (definitions == null) {
-            return beans;
-        }
-        for (Bean<?> bean : definitions) {
-            if (bean.getName() != null) {
-                T obj = CdiBeanManagerHelper.lookupBeanByNameAndType(beanManager, bean.getName(), type);
-                beans.put(bean.getName(), obj);
-            }
-        }
-        return beans;
-    }
-
-    @Override
-    public <T> Set<T> findByType(Class<T> type) {
-        ObjectHelper.notNull(type, "type");
-
-        LOG.trace("Lookups based of type {}", type);
-        Set<T> beans = new HashSet<T>();
-        Set<Bean<?>> definitions = beanManager.getBeans(type);
-
-        if (definitions == null) {
-            return beans;
-        }
-        for (Bean<?> bean : definitions) {
-            if (bean.getName() != null) {
-                T obj = CdiBeanManagerHelper.lookupBeanByNameAndType(beanManager, bean.getName(), type);
-                beans.add(obj);
-            }
-        }
-        return beans;
-    }
-
-    @Override
-    public Object lookup(String name) {
-        return lookupByName(name);
-    }
-
-    @Override
-    public <T> T lookup(String name, Class<T> type) {
-        return lookupByNameAndType(name, type);
-    }
-
-    @Override
-    public <T> Map<String, T> lookupByType(Class<T> type) {
-        return findByTypeWithName(type);
-    }
-
-    @Override
-    public String toString() {
-        return "CdiRegistry[" + System.identityHashCode(this) + "]";
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelBeanPostProcessor.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelBeanPostProcessor.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelBeanPostProcessor.java
new file mode 100644
index 0000000..85284fc
--- /dev/null
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelBeanPostProcessor.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.apache.camel.cdi;
+
+import java.lang.reflect.Field;
+import java.util.HashMap;
+import java.util.Map;
+import javax.enterprise.inject.InjectionException;
+import javax.enterprise.inject.UnsatisfiedResolutionException;
+import javax.enterprise.inject.spi.BeanManager;
+
+import org.apache.camel.BeanInject;
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Produce;
+import org.apache.camel.PropertyInject;
+import org.apache.camel.impl.CamelPostProcessorHelper;
+import org.apache.camel.impl.DefaultCamelBeanPostProcessor;
+import org.apache.camel.util.ReflectionHelper;
+
+@Vetoed
+final class CdiCamelBeanPostProcessor extends DefaultCamelBeanPostProcessor {
+
+    private final BeanManager manager;
+
+    private final Map<String, CamelPostProcessorHelper> postProcessorHelpers = new HashMap<>();
+
+    // TODO: proper support for multi Camel contexts and custom context qualifiers
+    CdiCamelBeanPostProcessor(BeanManager manager) {
+        this.manager = manager;
+    }
+
+    protected void injectFields(final Object bean, final String beanName) {
+        ReflectionHelper.doWithFields(bean.getClass(), new ReflectionHelper.FieldCallback() {
+            public void doWith(Field field) throws IllegalAccessException {
+                PropertyInject propertyInject = field.getAnnotation(PropertyInject.class);
+                if (propertyInject != null) {
+                    try {
+                        injectFieldProperty(field, propertyInject.value(), propertyInject.defaultValue(), propertyInject.context(), bean, beanName);
+                    } catch (Exception cause) {
+                        throw new InjectionException("Injection of [" + propertyInject + "] for field [" + field + "] failed!", cause);
+                    }
+                }
+
+                BeanInject beanInject = field.getAnnotation(BeanInject.class);
+                // TODO: proper support for multi Camel contexts
+                if (beanInject != null && getPostProcessorHelper().matchContext(beanInject.context())) {
+                    try {
+                        injectFieldBean(field, beanInject.value(), bean, beanName);
+                    } catch (Exception cause) {
+                        throw new InjectionException("Injection of [" + beanInject + "] for field [" + field + "] failed!", cause);
+                    }
+                }
+
+                EndpointInject endpointInject = field.getAnnotation(EndpointInject.class);
+                if (endpointInject != null) {
+                    try {
+                        injectField(field, endpointInject.uri(), endpointInject.ref(), endpointInject.property(), endpointInject.context(), bean, beanName);
+                    } catch (Exception cause) {
+                        throw new InjectionException("Injection of [" + endpointInject + "] for field [" + field + "] failed!", cause);
+                    }
+                }
+
+                Produce produce = field.getAnnotation(Produce.class);
+                if (produce != null) {
+                    try {
+                        injectField(field, produce.uri(), produce.ref(), produce.property(), produce.context(), bean, beanName);
+                    } catch (Exception cause) {
+                        throw new InjectionException("Injection of [" + produce + "] for field [" + field + "] failed!", cause);
+                    }
+                }
+            }
+        });
+    }
+
+    private void injectField(Field field, String uri, String ref, String property, String context, Object bean, String beanName) {
+        ReflectionHelper.setField(field, bean, getPostProcessorHelper(context).getInjectionValue(field.getType(), uri, ref, property, field.getName(), bean, beanName));
+    }
+
+    private void injectFieldProperty(Field field, String property, String defaultValue, String context, Object bean, String beanName) {
+        ReflectionHelper.setField(field, bean, getPostProcessorHelper(context).getInjectionPropertyValue(field.getType(), property, defaultValue, field.getName(), bean, beanName));
+    }
+
+    private CamelPostProcessorHelper getPostProcessorHelper(String contextName) {
+        CamelPostProcessorHelper helper = postProcessorHelpers.get(contextName);
+        if (helper == null) {
+            CamelContext context = getOrLookupCamelContext(contextName);
+            if (context == null) {
+                throw new UnsatisfiedResolutionException("No Camel context with name [" + contextName + "] is deployed!");
+            }
+            helper = new CamelPostProcessorHelper(context);
+            postProcessorHelpers.put(contextName, helper);
+        }
+        return helper;
+    }
+
+    private CamelContext getOrLookupCamelContext(String contextName) {
+        // TODO: proper support for custom context qualifiers
+        return BeanManagerHelper.getReferenceByType(manager, CamelContext.class, contextName.isEmpty() ? DefaultLiteral.INSTANCE : new ContextName.Literal(contextName));
+    }
+
+    @Override
+    public CamelContext getOrLookupCamelContext() {
+        return BeanManagerHelper.getReferenceByType(manager, CamelContext.class);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelContext.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelContext.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelContext.java
old mode 100644
new mode 100755
index df603c7..f5f775d
--- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelContext.java
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelContext.java
@@ -16,77 +16,23 @@
  */
 package org.apache.camel.cdi;
 
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-import javax.enterprise.inject.Instance;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.inject.Inject;
-
 import org.apache.camel.impl.DefaultCamelContext;
-import org.apache.camel.spi.Injector;
-import org.apache.camel.spi.Registry;
-import org.apache.camel.util.ObjectHelper;
 
 /**
- * CDI {@link org.apache.camel.CamelContext} class.
+ * CDI {@link org.apache.camel.CamelContext} class that can be extended
+ * to declare custom Camel context beans. Camel CDI is capable of managing
+ * any bean that implements {@code org.apache.camel.CamelContext},
+ * so that directly extending {@link org.apache.camel.impl.DefaultCamelContext}
+ * is an option to avoid having to depend on Camel CDI specific API, e.g.:
+ *
+ * <pre><code>
+ * {@literal @}ApplicationScoped
+ * {@literal @}ContextName("foo")
+ * public class FooCamelContext extends DefaultCamelContext {
+ * }
+ * </code></pre>
  */
+@Vetoed
 public class CdiCamelContext extends DefaultCamelContext {
 
-    private BeanManager beanManager;
-
-    public CdiCamelContext() {
-    }
-
-    @Inject
-    public void setBeanManager(Instance<BeanManager> beanManager) {
-        this.beanManager = beanManager.get();
-    }
-
-    @Inject
-    public void setRegistry(Instance<Registry> instance) {
-        if (isSingular(instance)) {
-            setRegistry(instance.get());
-        }
-    }
-
-    @Inject
-    public void setInjector(Instance<Injector> instance) {
-        if (isSingular(instance)) {
-            setInjector(instance.get());
-        }
-    }
-
-    private <T> boolean isSingular(Instance<T> instance) {
-        return !instance.isUnsatisfied() && !instance.isAmbiguous();
-    }
-
-    @PostConstruct
-    @Override
-    public void start() {
-        // make sure to use cdi capable bean registry and injector
-        if (!(getRegistry() instanceof CdiBeanRegistry)) {
-            setRegistry(new CdiBeanRegistry(beanManager));
-        }
-
-        if (!(getInjector() instanceof CdiInjector)) {
-            setInjector(new CdiInjector(getInjector()));
-        }
-
-        try {
-            super.start();
-        } catch (Exception e) {
-            throw ObjectHelper.wrapRuntimeCamelException(e);
-        }
-    }
-
-    @PreDestroy
-    @Override
-    public void stop() {
-        try {
-            super.stop();
-        } catch (Exception e) {
-            throw ObjectHelper.wrapRuntimeCamelException(e);
-        }
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelContextBean.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelContextBean.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelContextBean.java
new file mode 100644
index 0000000..08338a2
--- /dev/null
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelContextBean.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.apache.camel.cdi;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.InjectionTarget;
+import javax.enterprise.inject.spi.PassivationCapable;
+
+import org.apache.camel.impl.DefaultCamelContext;
+
+final class CdiCamelContextBean implements Bean<DefaultCamelContext>, PassivationCapable {
+
+    private final Set<Annotation> qualifiers;
+
+    private final Set<Type> types;
+
+    private final InjectionTarget<DefaultCamelContext> target;
+
+    CdiCamelContextBean(BeanManager manager, InjectionTarget<DefaultCamelContext> target) {
+        this.qualifiers = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(AnyLiteral.INSTANCE, DefaultLiteral.INSTANCE)));
+        this.types = Collections.unmodifiableSet(manager.createAnnotatedType(DefaultCamelContext.class).getTypeClosure());
+        this.target = target;
+    }
+
+    @Override
+    public Class<? extends Annotation> getScope() {
+        return ApplicationScoped.class;
+    }
+
+    @Override
+    public Set<Annotation> getQualifiers() {
+        return qualifiers;
+    }
+
+    @Override
+    public DefaultCamelContext create(CreationalContext<DefaultCamelContext> creational) {
+        DefaultCamelContext context = target.produce(creational);
+        target.inject(context, creational);
+        target.postConstruct(context);
+        creational.push(context);
+        return context;
+    }
+
+    @Override
+    public void destroy(DefaultCamelContext instance, CreationalContext<DefaultCamelContext> creational) {
+        target.preDestroy(instance);
+        target.dispose(instance);
+        creational.release();
+    }
+
+    @Override
+    public Class<DefaultCamelContext> getBeanClass() {
+        return DefaultCamelContext.class;
+    }
+
+    @Override
+    public Set<InjectionPoint> getInjectionPoints() {
+        return Collections.emptySet();
+    }
+
+    @Override
+    public String getName() {
+        // Not called as this is not a named bean
+        return null;
+    }
+
+    @Override
+    public String toString() {
+        return "Default CDI Camel Context";
+    }
+
+    @Override
+    public Set<Class<? extends Annotation>> getStereotypes() {
+        return Collections.emptySet();
+    }
+
+    @Override
+    public Set<Type> getTypes() {
+        return types;
+    }
+
+    @Override
+    public boolean isAlternative() {
+        return false;
+    }
+
+    @Override
+    public boolean isNullable() {
+        return false;
+    }
+
+    @Override
+    public String getId() {
+        return getClass().getName();
+    }
+}


[4/9] camel git commit: CAMEL-9201: Improved Camel CDI component

Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/AdvisedRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/AdvisedRouteTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/AdvisedRouteTest.java
new file mode 100644
index 0000000..61c33bb
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/AdvisedRouteTest.java
@@ -0,0 +1,105 @@
+/**
+ * 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.cdi.test;
+
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.AdviceWithRouteBuilder;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.bean.ManualStartupCamelContext;
+import org.apache.camel.cdi.bean.PropertyEndpointRoute;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.properties.PropertiesComponent;
+import org.apache.camel.model.ModelCamelContext;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.junit.InSequence;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+
+@RunWith(Arquillian.class)
+public class AdvisedRouteTest {
+
+    @Inject
+    @Uri("direct:inbound")
+    private ProducerTemplate inbound;
+
+    @Inject
+    @Uri("mock:outbound")
+    private MockEndpoint outbound;
+
+    @Produces
+    @ApplicationScoped
+    @Named("properties")
+    private static PropertiesComponent configuration() {
+        Properties properties = new Properties();
+        properties.put("from", "inbound");
+        properties.put("to", "direct:outbound");
+        properties.put("header.message", "n/a");
+        PropertiesComponent component = new PropertiesComponent();
+        component.setInitialProperties(properties);
+        return component;
+    }
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test classes
+            .addClasses(ManualStartupCamelContext.class, PropertyEndpointRoute.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    @InSequence(1)
+    public void adviseCamelContext(ModelCamelContext context) throws Exception {
+        context.getRouteDefinition("route").adviceWith(context, new AdviceWithRouteBuilder() {
+            @Override
+            public void configure() {
+                interceptSendToEndpoint("{{to}}").skipSendToOriginalEndpoint().to("mock:outbound");
+            }
+        });
+        context.startAllRoutes();
+    }
+
+    @Test
+    @InSequence(2)
+    public void sendMessageToInbound() throws InterruptedException {
+        outbound.expectedMessageCount(1);
+        outbound.expectedBodiesReceived("test");
+        outbound.expectedHeaderReceived("header", "n/a");
+        
+        inbound.sendBody("test");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, outbound);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/AmbiguousCamelContextTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/AmbiguousCamelContextTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/AmbiguousCamelContextTest.java
new file mode 100644
index 0000000..808c363
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/AmbiguousCamelContextTest.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.apache.camel.cdi.test;
+
+import org.apache.camel.ServiceStatus;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.bean.CustomPropertiesCamelContext;
+import org.apache.camel.cdi.bean.ManualStartupCamelContext;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Arquillian.class)
+public class AmbiguousCamelContextTest {
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test classes
+            .addClasses(ManualStartupCamelContext.class, CustomPropertiesCamelContext.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    public void test(ManualStartupCamelContext lifecycleCamelContext, CustomPropertiesCamelContext propertiesCamelContext) {
+        assertThat(lifecycleCamelContext.getStatus(), is(equalTo(ServiceStatus.Started)));
+        assertThat(propertiesCamelContext.getStatus(), is(equalTo(ServiceStatus.Started)));
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/BeanInjectTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/BeanInjectTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/BeanInjectTest.java
new file mode 100644
index 0000000..f5447ea
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/BeanInjectTest.java
@@ -0,0 +1,88 @@
+/**
+ * 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.cdi.test;
+
+import java.util.Properties;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.bean.BeanInjectBean;
+import org.apache.camel.cdi.bean.NamedCamelBean;
+import org.apache.camel.cdi.bean.PropertyInjectBean;
+import org.apache.camel.component.properties.PropertiesComponent;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Arquillian.class)
+public class BeanInjectTest {
+
+    @Inject
+    private BeanInjectBean bean;
+
+    @Produces
+    @ApplicationScoped
+    @Named("properties")
+    private static PropertiesComponent configuration() {
+        Properties properties = new Properties();
+        properties.put("property", "value");
+        PropertiesComponent component = new PropertiesComponent();
+        component.setInitialProperties(properties);
+        return component;
+    }
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test classes
+            .addClasses(BeanInjectBean.class, PropertyInjectBean.class, NamedCamelBean.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    public void beanInjectField() {
+        assertThat(bean.getInjectBeanField(), is(notNullValue()));
+        assertThat(bean.getInjectBeanField().getProperty(), is(equalTo("value")));
+    }
+
+    @Test
+    public void beanInjectMethod() {
+        assertThat(bean.getInjectBeanMethod(), is(notNullValue()));
+        assertThat(bean.getInjectBeanMethod().getProperty(), is(equalTo("value")));
+    }
+
+    @Test
+    public void beanInjectNamed() {
+        assertThat(bean.getInjectBeanNamed(), is(notNullValue()));
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/CamelContextAwareTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/CamelContextAwareTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/CamelContextAwareTest.java
new file mode 100644
index 0000000..5b432ec
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/CamelContextAwareTest.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.apache.camel.cdi.test;
+
+import javax.inject.Inject;
+
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.bean.CamelContextAwareBean;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Arquillian.class)
+public class CamelContextAwareTest {
+
+    @Inject
+    private CamelContextAwareBean bean;
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test class
+            .addClass(CamelContextAwareBean.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    public void camelContextAware() {
+        assertThat(bean.getCamelContext(), is(notNullValue()));
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/CamelContextProducerFieldTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/CamelContextProducerFieldTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/CamelContextProducerFieldTest.java
new file mode 100644
index 0000000..656ad5a
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/CamelContextProducerFieldTest.java
@@ -0,0 +1,97 @@
+/**
+ * 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.cdi.test;
+
+import java.util.concurrent.TimeUnit;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.ServiceStatus;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.bean.NamedCamelBean;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Arquillian.class)
+public class CamelContextProducerFieldTest {
+
+    @Named
+    @Produces
+    @ApplicationScoped
+    private static CamelContext context = new DefaultCamelContext();
+
+    @Inject
+    @Uri("direct:inbound")
+    private ProducerTemplate inbound;
+
+    @Inject
+    @Uri("mock:outbound")
+    private MockEndpoint outbound;
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test class
+            .addClass(NamedCamelBean.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    public void verifyProducedCamelContext(CamelContext context) {
+        assertThat("The producer field sets the context name!", context.getName(), is(equalTo("context")));
+        assertThat("The producer field starts the Camel context!", context.getStatus(), is(equalTo(ServiceStatus.Started)));
+    }
+
+    @Test
+    public void sendMessageToInbound() throws InterruptedException {
+        outbound.expectedMessageCount(1);
+        outbound.expectedBodiesReceived("test-processed");
+
+        inbound.sendBody("test");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, outbound);
+    }
+
+    private static class NamedBeanRoute extends RouteBuilder {
+        @Override
+        public void configure() {
+            from("direct:inbound").bean("beanName").to("mock:outbound");
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/CamelContextProducerMethodTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/CamelContextProducerMethodTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/CamelContextProducerMethodTest.java
new file mode 100644
index 0000000..24e9319
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/CamelContextProducerMethodTest.java
@@ -0,0 +1,89 @@
+/**
+ * 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.cdi.test;
+
+import java.util.concurrent.TimeUnit;
+import javax.inject.Inject;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.ServiceStatus;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.bean.CamelContextProducerMethod;
+import org.apache.camel.cdi.bean.NamedCamelBean;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Arquillian.class)
+public class CamelContextProducerMethodTest {
+
+    @Inject
+    @Uri("direct:inbound")
+    private ProducerTemplate inbound;
+
+    @Inject
+    @Uri("mock:outbound")
+    private MockEndpoint outbound;
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test classes
+            .addClasses(CamelContextProducerMethod.class, NamedCamelBean.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    public void verifyProducedCamelContext(CamelContext context) {
+        assertThat("The producer method sets the context name!", context.getName(), is(equalTo("camel-producer-method")));
+        assertThat("The producer method starts the Camel context!", context.getStatus(), is(equalTo(ServiceStatus.Started)));
+    }
+
+    @Test
+    public void sendMessageToInbound() throws InterruptedException {
+        outbound.expectedMessageCount(1);
+        outbound.expectedBodiesReceived("test-processed");
+
+        inbound.sendBody("test");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, outbound);
+    }
+
+    private static class NamedBeanRoute extends RouteBuilder {
+        @Override
+        public void configure() {
+            from("direct:inbound").bean("beanName").to("mock:outbound");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/CamelEventEndpointTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/CamelEventEndpointTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/CamelEventEndpointTest.java
new file mode 100644
index 0000000..f298546
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/CamelEventEndpointTest.java
@@ -0,0 +1,143 @@
+/**
+ * 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.cdi.test;
+
+import java.util.EventObject;
+import javax.inject.Inject;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.CdiEventEndpoint;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.management.event.CamelContextStartedEvent;
+import org.apache.camel.management.event.ExchangeCompletedEvent;
+import org.apache.camel.management.event.ExchangeCreatedEvent;
+import org.apache.camel.management.event.ExchangeSendingEvent;
+import org.apache.camel.management.event.ExchangeSentEvent;
+import org.apache.camel.management.event.RouteStartedEvent;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.either;
+import static org.hamcrest.Matchers.hasProperty;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Arquillian.class)
+public class CamelEventEndpointTest {
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test class
+            .addClass(CamelEventRoute.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    public void camelStartedEvent(@Uri("mock:started") MockEndpoint started) {
+        assertThat("Event fired is incorrect!", started.getExchanges(),
+            contains(
+                hasProperty("in",
+                    hasProperty("body", instanceOf(CamelContextStartedEvent.class)))));
+    }
+
+    @Test
+    public void camelAllEvents(@Uri("mock:events") MockEndpoint events) {
+        assertThat("Events fired are incorrect!", events.getExchanges(),
+            // We cannot rely on the delivery order of the camel context started event being fired and observed by both CDI event endpoints
+            either(
+                contains(
+                    // Started route: route1
+                    hasProperty("in", hasProperty("body", instanceOf(ExchangeCreatedEvent.class))),
+                    hasProperty("in", hasProperty("body", instanceOf(ExchangeSendingEvent.class))),
+                    hasProperty("in", hasProperty("body", instanceOf(RouteStartedEvent.class))),
+                    hasProperty("in", hasProperty("body", instanceOf(ExchangeSentEvent.class))),
+                    hasProperty("in", hasProperty("body", instanceOf(ExchangeCompletedEvent.class))),
+                    // Started route: route2
+                    hasProperty("in", hasProperty("body", instanceOf(ExchangeCreatedEvent.class))),
+                    hasProperty("in", hasProperty("body", instanceOf(ExchangeSendingEvent.class))),
+                    hasProperty("in", hasProperty("body", instanceOf(RouteStartedEvent.class))),
+                    hasProperty("in", hasProperty("body", instanceOf(ExchangeSentEvent.class))),
+                    hasProperty("in", hasProperty("body", instanceOf(ExchangeCompletedEvent.class))),
+                    // Started CamelContext: camel-cdi
+                    hasProperty("in", hasProperty("body", instanceOf(ExchangeCreatedEvent.class))),
+                    hasProperty("in", hasProperty("body", instanceOf(ExchangeSendingEvent.class))),
+                    hasProperty("in", hasProperty("body", instanceOf(CamelContextStartedEvent.class))),
+                    hasProperty("in", hasProperty("body", instanceOf(ExchangeSentEvent.class))),
+                    hasProperty("in", hasProperty("body", instanceOf(ExchangeCompletedEvent.class))),
+                    // Started CamelContext: camel-cdi (for CdiEventEndpoint<CamelContextStartedEvent> started)
+                    hasProperty("in", hasProperty("body", instanceOf(ExchangeCreatedEvent.class))),
+                    hasProperty("in", hasProperty("body", instanceOf(ExchangeSendingEvent.class))),
+                    hasProperty("in", hasProperty("body", instanceOf(ExchangeSentEvent.class))),
+                    hasProperty("in", hasProperty("body", instanceOf(ExchangeCompletedEvent.class)))
+            )).or(
+                contains(
+                    // Started route: route1
+                    hasProperty("in", hasProperty("body", instanceOf(ExchangeCreatedEvent.class))),
+                    hasProperty("in", hasProperty("body", instanceOf(ExchangeSendingEvent.class))),
+                    hasProperty("in", hasProperty("body", instanceOf(RouteStartedEvent.class))),
+                    hasProperty("in", hasProperty("body", instanceOf(ExchangeSentEvent.class))),
+                    hasProperty("in", hasProperty("body", instanceOf(ExchangeCompletedEvent.class))),
+                    // Started route: route2
+                    hasProperty("in", hasProperty("body", instanceOf(ExchangeCreatedEvent.class))),
+                    hasProperty("in", hasProperty("body", instanceOf(ExchangeSendingEvent.class))),
+                    hasProperty("in", hasProperty("body", instanceOf(RouteStartedEvent.class))),
+                    hasProperty("in", hasProperty("body", instanceOf(ExchangeSentEvent.class))),
+                    hasProperty("in", hasProperty("body", instanceOf(ExchangeCompletedEvent.class))),
+                    // Started CamelContext: camel-cdi (for CdiEventEndpoint<CamelContextStartedEvent> started)
+                    hasProperty("in", hasProperty("body", instanceOf(ExchangeCreatedEvent.class))),
+                    hasProperty("in", hasProperty("body", instanceOf(ExchangeSendingEvent.class))),
+                    hasProperty("in", hasProperty("body", instanceOf(ExchangeSentEvent.class))),
+                    hasProperty("in", hasProperty("body", instanceOf(ExchangeCompletedEvent.class))),
+                    // Started CamelContext: camel-cdi
+                    hasProperty("in", hasProperty("body", instanceOf(ExchangeCreatedEvent.class))),
+                    hasProperty("in", hasProperty("body", instanceOf(ExchangeSendingEvent.class))),
+                    hasProperty("in", hasProperty("body", instanceOf(CamelContextStartedEvent.class))),
+                    hasProperty("in", hasProperty("body", instanceOf(ExchangeSentEvent.class))),
+                    hasProperty("in", hasProperty("body", instanceOf(ExchangeCompletedEvent.class)))
+                )
+            )
+        );
+    }
+}
+
+class CamelEventRoute extends RouteBuilder {
+
+    @Inject
+    private CdiEventEndpoint<CamelContextStartedEvent> started;
+
+    @Inject
+    private CdiEventEndpoint<EventObject> events;
+
+    @Override
+    public void configure() {
+        from(events).startupOrder(1).to("mock:events");
+        from(started).startupOrder(2).to("mock:started");
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/CamelEventNotifierTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/CamelEventNotifierTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/CamelEventNotifierTest.java
new file mode 100644
index 0000000..3a07d9f
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/CamelEventNotifierTest.java
@@ -0,0 +1,151 @@
+/**
+ * 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.cdi.test;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.bean.SimpleCamelRoute;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.management.event.AbstractExchangeEvent;
+import org.apache.camel.management.event.CamelContextStartedEvent;
+import org.apache.camel.management.event.CamelContextStartingEvent;
+import org.apache.camel.management.event.CamelContextStoppedEvent;
+import org.apache.camel.management.event.CamelContextStoppingEvent;
+import org.apache.camel.management.event.ExchangeCompletedEvent;
+import org.apache.camel.management.event.ExchangeCreatedEvent;
+import org.apache.camel.management.event.ExchangeSendingEvent;
+import org.apache.camel.management.event.ExchangeSentEvent;
+import org.hamcrest.Matchers;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.junit.InSequence;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Arquillian.class)
+public class CamelEventNotifierTest {
+
+    @Inject
+    @Uri("direct:start")
+    private ProducerTemplate inbound;
+
+    @Inject
+    @Uri("mock:result")
+    private MockEndpoint outbound;
+
+    @Produces
+    @ApplicationScoped
+    private List<Class> firedEvents = new ArrayList<>();
+
+    private void onCamelContextStartingEvent(@Observes CamelContextStartingEvent event, List<Class> events) {
+        events.add(CamelContextStartingEvent.class);
+    }
+
+    private void onCamelContextStartedEvent(@Observes CamelContextStartedEvent event, List<Class> events) {
+        events.add(CamelContextStartedEvent.class);
+    }
+
+    private void onExchangeEvent(@Observes AbstractExchangeEvent event, List<Class> events) {
+        events.add(event.getClass());
+    }
+
+    private void onCamelContextStoppingEvent(@Observes CamelContextStoppingEvent event, List<Class> events) {
+        events.add(CamelContextStoppingEvent.class);
+    }
+
+    private void onCamelContextStoppedEvent(@Observes CamelContextStoppedEvent event, List<Class> events) {
+        events.add(CamelContextStoppedEvent.class);
+    }
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test class
+            .addClass(SimpleCamelRoute.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    @InSequence(1)
+    public void startedCamelContext(List<Class> events) throws Exception {
+        assertThat("Events fired are incorrect", events,
+            Matchers.<Class>contains(
+                CamelContextStartingEvent.class,
+                CamelContextStartedEvent.class));
+    }
+
+    @Test
+    @InSequence(2)
+    public void sendMessageToInbound(List<Class> events) throws InterruptedException {
+        outbound.expectedMessageCount(1);
+        outbound.expectedBodiesReceived("test");
+
+        inbound.sendBody("test");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, outbound);
+
+        assertThat("Events fired are incorrect", events,
+            Matchers.<Class>contains(
+                CamelContextStartingEvent.class,
+                CamelContextStartedEvent.class,
+                ExchangeSendingEvent.class,
+                ExchangeCreatedEvent.class,
+                ExchangeSendingEvent.class,
+                ExchangeSentEvent.class,
+                ExchangeCompletedEvent.class,
+                ExchangeSentEvent.class));
+    }
+
+    @Test
+    @InSequence(3)
+    public void stopCamelContext(CamelContext context, List<Class> events) throws Exception {
+        context.stop();
+
+        assertThat("Events fired are incorrect", events,
+            Matchers.<Class>contains(
+                CamelContextStartingEvent.class,
+                CamelContextStartedEvent.class,
+                ExchangeSendingEvent.class,
+                ExchangeCreatedEvent.class,
+                ExchangeSendingEvent.class,
+                ExchangeSentEvent.class,
+                ExchangeCompletedEvent.class,
+                ExchangeSentEvent.class,
+                CamelContextStoppingEvent.class,
+                CamelContextStoppedEvent.class));
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/ConsumeMethodTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/ConsumeMethodTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/ConsumeMethodTest.java
new file mode 100644
index 0000000..3f112c9
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/ConsumeMethodTest.java
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cdi.test;
+
+import java.util.concurrent.TimeUnit;
+import javax.inject.Inject;
+
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.bean.ConsumeMethodBean;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+
+@RunWith(Arquillian.class)
+public class ConsumeMethodTest {
+
+    @Inject
+    @Uri("seda:inbound")
+    private ProducerTemplate inbound;
+
+    @Inject
+    @Uri("mock:outbound")
+    private MockEndpoint outbound;
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test class
+            .addClass(ConsumeMethodBean.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    public void consumeAnnotation() throws InterruptedException {
+        outbound.expectedMessageCount(1);
+        outbound.expectedBodiesReceived("test");
+
+        inbound.sendBody("test");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, outbound);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/ContextComponentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/ContextComponentTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/ContextComponentTest.java
new file mode 100644
index 0000000..fe1a80e
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/ContextComponentTest.java
@@ -0,0 +1,92 @@
+/**
+ * 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.cdi.test;
+
+import java.util.concurrent.TimeUnit;
+import javax.inject.Inject;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.bean.DefaultCamelContextBean;
+import org.apache.camel.cdi.bean.FirstNamedCamelContextBean;
+import org.apache.camel.cdi.bean.FirstNamedCamelContextRoute;
+import org.apache.camel.cdi.bean.SecondNamedCamelContextBean;
+import org.apache.camel.cdi.bean.SecondNamedCamelContextRoute;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.junit.InSequence;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(Arquillian.class)
+public class ContextComponentTest {
+
+    @Inject
+    private CamelContext main;
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test classes
+            .addClasses(
+                DefaultCamelContextBean.class,
+                FirstNamedCamelContextBean.class,
+                FirstNamedCamelContextRoute.class,
+                SecondNamedCamelContextBean.class,
+                SecondNamedCamelContextRoute.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    @InSequence(1)
+    public void addRouteToMainContext() throws Exception {
+        main.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:inbound").to("first:in");
+                // FIXME: The context component does not support multiple logical endpoints
+                // with the same remaining defined in two distinct Camel contexts.
+                // See https://issues.apache.org/jira/browse/CAMEL-9200.
+                // from("first:out").to("second:in");
+                from("first:out").to("mock:outbound");
+            }
+        });
+    }
+
+    @Test
+    @InSequence(2)
+    public void sendMessageToInbound(@Uri("direct:inbound") ProducerTemplate inbound,
+                                     @Uri("mock:outbound") MockEndpoint outbound) throws InterruptedException {
+        outbound.expectedMessageCount(1);
+        outbound.expectedBodiesReceived("first-test");
+
+        inbound.sendBody("test");
+
+        MockEndpoint.assertIsSatisfied(1L, TimeUnit.SECONDS, outbound);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/CustomCamelContextTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/CustomCamelContextTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/CustomCamelContextTest.java
new file mode 100644
index 0000000..cf46c74
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/CustomCamelContextTest.java
@@ -0,0 +1,90 @@
+/**
+ * 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.cdi.test;
+
+import java.util.concurrent.TimeUnit;
+import javax.inject.Inject;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.ServiceStatus;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.bean.ManualStartupCamelContext;
+import org.apache.camel.cdi.bean.UriEndpointRoute;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.junit.InSequence;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Arquillian.class)
+public class CustomCamelContextTest {
+
+    @Inject
+    @Uri("direct:inbound")
+    private ProducerTemplate inbound;
+
+    @Inject
+    @Uri("mock:outbound")
+    private MockEndpoint outbound;
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test classes
+            .addClasses(ManualStartupCamelContext.class, UriEndpointRoute.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    @InSequence(1)
+    public void verifyCamelContext(CamelContext context) {
+        assertThat(context.getName(), is(equalTo("manual-startup")));
+
+        assertThat(inbound.getCamelContext().getName(), is(equalTo(context.getName())));
+        assertThat(outbound.getCamelContext().getName(), is(equalTo(context.getName())));
+
+        assertThat(context.getRouteStatus("uri-route"), is(equalTo(ServiceStatus.Stopped)));
+    }
+
+    @Test
+    @InSequence(2)
+    public void sendMessageToInbound(CamelContext context) throws Exception {
+        context.startAllRoutes();
+
+        outbound.expectedMessageCount(1);
+        outbound.expectedBodiesReceived("test");
+
+        inbound.sendBody("test");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, outbound);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/DefaultCamelContextTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/DefaultCamelContextTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/DefaultCamelContextTest.java
new file mode 100644
index 0000000..761ea8e
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/DefaultCamelContextTest.java
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cdi.test;
+
+import java.util.concurrent.TimeUnit;
+import javax.inject.Inject;
+
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.bean.SimpleCamelRoute;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+
+@RunWith(Arquillian.class)
+public class DefaultCamelContextTest {
+
+    @Inject
+    @Uri("direct:start")
+    private ProducerTemplate inbound;
+
+    @Inject
+    @Uri("mock:result")
+    private MockEndpoint outbound;
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test class
+            .addClass(SimpleCamelRoute.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    public void sendMessageToInbound() throws InterruptedException {
+        outbound.expectedMessageCount(1);
+        outbound.expectedBodiesReceived("test");
+
+        inbound.sendBody("test");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, outbound);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/EndpointInjectTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/EndpointInjectTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/EndpointInjectTest.java
new file mode 100644
index 0000000..a49dca4
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/EndpointInjectTest.java
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cdi.test;
+
+import java.util.concurrent.TimeUnit;
+import javax.inject.Inject;
+
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.bean.EndpointInjectRoute;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+
+@RunWith(Arquillian.class)
+public class EndpointInjectTest {
+
+    @Inject
+    @Uri("direct:inbound")
+    private ProducerTemplate inbound;
+
+    @Inject
+    @Uri("mock:outbound")
+    private MockEndpoint outbound;
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test class
+            .addClass(EndpointInjectRoute.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    public void sendMessageToInbound() throws InterruptedException {
+        outbound.expectedMessageCount(1);
+        outbound.expectedBodiesReceived("test");
+        
+        inbound.sendBody("test");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, outbound);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/EventComponentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/EventComponentTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/EventComponentTest.java
new file mode 100644
index 0000000..424a7a8
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/EventComponentTest.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.apache.camel.cdi.test;
+
+import javax.enterprise.context.ApplicationScoped;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+
+@RunWith(Arquillian.class)
+public class EventComponentTest {
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    // We should ideally use an ExpectedException JUnit rule to assert the content of the exception
+    // thrown at deployment time. Unfortunately, OpenWebBeans does not enable access to the underlying
+    // cause added as deployment exception. To work-around that, we delay the start of the Camel context
+    // at runtime.
+
+    @Test
+    public void createEventEndpointByUri(NotStartedCamelContext context) {
+        try {
+            context.start(true);
+        } catch (Exception exception) {
+            Throwable cause = exception.getCause().getCause();
+            assertThat("Exception cause is not an UnsupportedOperationException!", cause, is(instanceOf(UnsupportedOperationException.class)));
+            assertThat("Incorrect exception message!", cause.getMessage(), is(equalTo("Creating CDI event endpoint isn't supported. Use @Inject CdiEventEndpoint instead")));
+            return;
+        }
+        fail("CDI event endpoint creation by URI should throw an exception!");
+    }
+
+    static class CdiEventComponentRoute extends RouteBuilder {
+
+        @Override
+        public void configure() {
+            from("cdi-event://Object").log("Unsupported operation!");
+        }
+    }
+
+    @ApplicationScoped
+    static class NotStartedCamelContext extends DefaultCamelContext {
+
+        @Override
+        public void start() throws Exception {
+            start(false);
+        }
+
+        void start(boolean start) throws Exception {
+            if (start) {
+                super.start();
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/EventEndpointCdi12Test.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/EventEndpointCdi12Test.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/EventEndpointCdi12Test.java
new file mode 100644
index 0000000..bf78aa3
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/EventEndpointCdi12Test.java
@@ -0,0 +1,277 @@
+/**
+ * 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.cdi.test;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.event.Event;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Default;
+import javax.enterprise.util.TypeLiteral;
+import javax.inject.Inject;
+
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.bean.EventConsumingRoute;
+import org.apache.camel.cdi.bean.EventProducingRoute;
+import org.apache.camel.cdi.pojo.EventPayload;
+import org.apache.camel.cdi.qualifier.BarQualifier;
+import org.apache.camel.cdi.qualifier.FooQualifier;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+import static org.hamcrest.Matchers.contains;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Arquillian.class)
+public class EventEndpointCdi12Test {
+
+    @Inject
+    @Uri("mock:consumeObject")
+    private MockEndpoint consumeObject;
+
+    @Inject
+    @Uri("mock:consumeString")
+    private MockEndpoint consumeString;
+
+    @Inject
+    @Uri("mock:consumeStringPayload")
+    private MockEndpoint consumeStringPayload;
+
+    @Inject
+    @Uri("mock:consumeIntegerPayload")
+    private MockEndpoint consumeIntegerPayload;
+
+    @Inject
+    @Uri("mock:consumeFooQualifier")
+    private MockEndpoint consumeFooQualifier;
+
+    @Inject
+    @Uri("mock:consumeBarQualifier")
+    private MockEndpoint consumeBarQualifier;
+
+    @Inject
+    @Uri("direct:produceObject")
+    private ProducerTemplate produceObject;
+
+    @Inject
+    @Uri("direct:produceString")
+    private ProducerTemplate produceString;
+
+    @Inject
+    @Uri("direct:produceStringPayload")
+    private ProducerTemplate produceStringPayload;
+
+    @Inject
+    @Uri("direct:produceIntegerPayload")
+    private ProducerTemplate produceIntegerPayload;
+
+    @Inject
+    @Uri("direct:produceFooQualifier")
+    private ProducerTemplate produceFooQualifier;
+
+    @Inject
+    @Uri("direct:produceBarQualifier")
+    private ProducerTemplate produceBarQualifier;
+
+    @Inject
+    private Event<Object> objectEvent;
+
+    @Inject
+    private Event<EventPayload<String>> stringPayloadEvent;
+
+    @Inject
+    private Event<EventPayload<Integer>> integerPayloadEvent;
+
+    @Inject
+    private EventObserver observer;
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test classes
+            .addClasses(EventConsumingRoute.class, EventProducingRoute.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Before
+    public void resetCollectedEventsAndMockEndpoints() {
+        observer.reset();
+        consumeObject.reset();
+        consumeString.reset();
+        consumeStringPayload.reset();
+        consumeIntegerPayload.reset();
+        consumeFooQualifier.reset();
+        consumeBarQualifier.reset();
+    }
+
+    @Test
+    public void sendEventsToConsumers() throws InterruptedException {
+        consumeObject.expectedMessageCount(8);
+        consumeObject.expectedBodiesReceived(1234, new EventPayload<>("foo"), new EventPayload<>("bar"), "test", new EventPayload<>(1), new EventPayload<>(2), 123L, 987L);
+
+        consumeString.expectedMessageCount(1);
+        consumeString.expectedBodiesReceived("test");
+
+        consumeStringPayload.expectedMessageCount(2);
+        consumeStringPayload.expectedBodiesReceived(new EventPayload<>("foo"), new EventPayload<>("bar"));
+
+        consumeIntegerPayload.expectedMessageCount(2);
+        consumeIntegerPayload.expectedBodiesReceived(new EventPayload<>(1), new EventPayload<>(2));
+
+        consumeFooQualifier.expectedMessageCount(1);
+        consumeFooQualifier.expectedBodiesReceived(123L);
+
+        consumeBarQualifier.expectedMessageCount(1);
+        consumeBarQualifier.expectedBodiesReceived(987L);
+
+        objectEvent.select(Integer.class).fire(1234);
+        objectEvent.select(new TypeLiteral<EventPayload<String>>() {
+        }).fire(new EventPayload<>("foo"));
+        stringPayloadEvent.select(new BarQualifier.Literal()).fire(new EventPayload<>("bar"));
+        objectEvent.select(String.class).fire("test");
+        integerPayloadEvent.fire(new EventPayload<>(1));
+        integerPayloadEvent.fire(new EventPayload<>(2));
+        objectEvent.select(Long.class, new FooQualifier.Literal()).fire(123L);
+        objectEvent.select(Long.class, new BarQualifier.Literal()).fire(987L);
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, consumeObject, consumeString, consumeStringPayload, consumeIntegerPayload, consumeFooQualifier, consumeBarQualifier);
+    }
+
+    @Test
+    public void sendMessagesToProducers() {
+        produceObject.sendBody("string");
+        EventPayload foo = new EventPayload<>("foo");
+        produceStringPayload.sendBody(foo);
+        produceObject.sendBody(1234);
+        produceString.sendBody("test");
+        EventPayload<Integer> bar = new EventPayload<>(2);
+        produceIntegerPayload.sendBody(bar);
+        EventPayload<Integer> baz = new EventPayload<>(12);
+        produceIntegerPayload.sendBody(baz);
+        produceFooQualifier.sendBody(456L);
+        produceBarQualifier.sendBody(495L);
+        produceObject.sendBody(777L);
+
+        assertThat(observer.getObjectEvents(), contains("string", foo, 1234, "test", bar, baz, 456L, 495L, 777L));
+        assertThat(observer.getStringEvents(), contains("string", "test"));
+        assertThat(observer.getStringPayloadEvents(), contains(foo));
+        assertThat(observer.getIntegerPayloadEvents(), contains(bar, baz));
+        assertThat(observer.getDefaultQualifierEvents(), contains("string", foo, 1234, "test", bar, baz, 777L));
+        assertThat(observer.getFooQualifierEvents(), contains(456L));
+        assertThat(observer.getBarQualifierEvents(), contains(495L));
+    }
+
+    @ApplicationScoped
+    static class EventObserver {
+
+        private final List<Object> objectEvents = new ArrayList<>();
+
+        private final List<Object> defaultQualifierEvents = new ArrayList<>();
+
+        private final List<String> stringEvents = new ArrayList<>();
+
+        private final List<EventPayload<String>> stringPayloadEvents = new ArrayList<>();
+
+        private final List<EventPayload<Integer>> integerPayloadEvents = new ArrayList<>();
+
+        private final List<Long> fooQualifierEvents = new ArrayList<>();
+
+        private final List<Long> barQualifierEvents = new ArrayList<>();
+
+        void collectObjectEvents(@Observes Object event) {
+            objectEvents.add(event);
+        }
+
+        void collectStringEvents(@Observes String event) {
+            stringEvents.add(event);
+        }
+
+        void collectStringPayloadEvents(@Observes EventPayload<String> event) {
+            stringPayloadEvents.add(event);
+        }
+
+        void collectIntegerPayloadEvents(@Observes EventPayload<Integer> event) {
+            integerPayloadEvents.add(event);
+        }
+
+        void collectDefaultQualifierEvents(@Observes @Default Object event) {
+            defaultQualifierEvents.add(event);
+        }
+
+        void collectFooQualifierEvents(@Observes @FooQualifier Long event) {
+            fooQualifierEvents.add(event);
+        }
+
+        void collectBarQualifierEvents(@Observes @BarQualifier Long event) {
+            barQualifierEvents.add(event);
+        }
+
+        List<Object> getObjectEvents() {
+            return objectEvents;
+        }
+
+        List<String> getStringEvents() {
+            return stringEvents;
+        }
+
+        List<EventPayload<String>> getStringPayloadEvents() {
+            return stringPayloadEvents;
+        }
+
+        List<EventPayload<Integer>> getIntegerPayloadEvents() {
+            return integerPayloadEvents;
+        }
+
+        List<Object> getDefaultQualifierEvents() {
+            return defaultQualifierEvents;
+        }
+
+        List<Long> getFooQualifierEvents() {
+            return fooQualifierEvents;
+        }
+
+        List<Long> getBarQualifierEvents() {
+            return barQualifierEvents;
+        }
+
+        void reset() {
+            objectEvents.clear();
+            stringEvents.clear();
+            stringPayloadEvents.clear();
+            integerPayloadEvents.clear();
+            defaultQualifierEvents.clear();
+            fooQualifierEvents.clear();
+            barQualifierEvents.clear();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/EventEndpointTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/EventEndpointTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/EventEndpointTest.java
new file mode 100644
index 0000000..fde16fe
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/EventEndpointTest.java
@@ -0,0 +1,282 @@
+/**
+ * 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.cdi.test;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.event.Event;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Default;
+import javax.inject.Inject;
+
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.bean.EventConsumingRouteCdi10;
+import org.apache.camel.cdi.bean.EventProducingRouteCdi10;
+import org.apache.camel.cdi.pojo.EventPayload;
+import org.apache.camel.cdi.pojo.EventPayloadInteger;
+import org.apache.camel.cdi.pojo.EventPayloadString;
+import org.apache.camel.cdi.qualifier.BarQualifier;
+import org.apache.camel.cdi.qualifier.FooQualifier;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+import static org.hamcrest.Matchers.contains;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Arquillian.class)
+public class EventEndpointTest {
+
+    @Inject
+    @Uri("mock:consumeObject")
+    private MockEndpoint consumeObject;
+
+    @Inject
+    @Uri("mock:consumeString")
+    private MockEndpoint consumeString;
+
+    @Inject
+    @Uri("mock:consumeStringPayload")
+    private MockEndpoint consumeStringPayload;
+
+    @Inject
+    @Uri("mock:consumeIntegerPayload")
+    private MockEndpoint consumeIntegerPayload;
+
+    @Inject
+    @Uri("mock:consumeFooQualifier")
+    private MockEndpoint consumeFooQualifier;
+
+    @Inject
+    @Uri("mock:consumeBarQualifier")
+    private MockEndpoint consumeBarQualifier;
+
+    @Inject
+    @Uri("direct:produceObject")
+    private ProducerTemplate produceObject;
+
+    @Inject
+    @Uri("direct:produceString")
+    private ProducerTemplate produceString;
+
+    @Inject
+    @Uri("direct:produceStringPayload")
+    private ProducerTemplate produceStringPayload;
+
+    @Inject
+    @Uri("direct:produceIntegerPayload")
+    private ProducerTemplate produceIntegerPayload;
+
+    @Inject
+    @Uri("direct:produceFooQualifier")
+    private ProducerTemplate produceFooQualifier;
+
+    @Inject
+    @Uri("direct:produceBarQualifier")
+    private ProducerTemplate produceBarQualifier;
+
+    @Inject
+    private Event<Object> objectEvent;
+
+    @Inject
+    private Event<EventPayload<String>> stringPayloadEvent;
+
+    @Inject
+    private Event<EventPayload<Integer>> integerPayloadEvent;
+
+    @Inject
+    private EventObserver observer;
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test classes
+            .addClasses(
+                EventConsumingRouteCdi10.class,
+                EventProducingRouteCdi10.class,
+                EventPayloadString.class,
+                EventPayloadInteger.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Before
+    public void resetCollectedEventsAndMockEndpoints() {
+        observer.reset();
+        consumeObject.reset();
+        consumeString.reset();
+        consumeStringPayload.reset();
+        consumeIntegerPayload.reset();
+        consumeFooQualifier.reset();
+        consumeBarQualifier.reset();
+    }
+
+    @Test
+    public void sendEventsToConsumers() throws InterruptedException {
+        consumeObject.expectedMessageCount(8);
+        consumeObject.expectedBodiesReceived(1234, new EventPayloadString("foo"), new EventPayloadString("bar"), "test", new EventPayloadInteger(1), new EventPayloadInteger(2), 123L, 987L);
+
+        consumeString.expectedMessageCount(1);
+        consumeString.expectedBodiesReceived("test");
+
+        consumeStringPayload.expectedMessageCount(2);
+        consumeStringPayload.expectedBodiesReceived(new EventPayloadString("foo"), new EventPayloadString("bar"));
+
+        consumeIntegerPayload.expectedMessageCount(2);
+        consumeIntegerPayload.expectedBodiesReceived(new EventPayloadInteger(1), new EventPayloadInteger(2));
+
+        consumeFooQualifier.expectedMessageCount(1);
+        consumeFooQualifier.expectedBodiesReceived(123L);
+
+        consumeBarQualifier.expectedMessageCount(1);
+        consumeBarQualifier.expectedBodiesReceived(987L);
+
+        objectEvent.select(Integer.class).fire(1234);
+        objectEvent.select(EventPayloadString.class).fire(new EventPayloadString("foo"));
+        stringPayloadEvent.select(new BarQualifier.Literal()).fire(new EventPayloadString("bar"));
+        objectEvent.select(String.class).fire("test");
+        integerPayloadEvent.fire(new EventPayloadInteger(1));
+        integerPayloadEvent.fire(new EventPayloadInteger(2));
+        objectEvent.select(Long.class, new FooQualifier.Literal()).fire(123L);
+        objectEvent.select(Long.class, new BarQualifier.Literal()).fire(987L);
+
+        //assertIsSatisfied(2L, TimeUnit.SECONDS, consumeObject, consumeString, consumeStringPayload, consumeIntegerPayload, consumeFooQualifier, consumeBarQualifier);
+        assertIsSatisfied(2L, TimeUnit.SECONDS, consumeObject, consumeString,  consumeFooQualifier, consumeBarQualifier);
+    }
+
+    @Test
+    public void sendMessagesToProducers() {
+        produceObject.sendBody("string");
+        EventPayload foo = new EventPayloadString("foo");
+        produceStringPayload.sendBody(foo);
+        produceObject.sendBody(1234);
+        produceString.sendBody("test");
+        EventPayload<Integer> bar = new EventPayloadInteger(2);
+        produceIntegerPayload.sendBody(bar);
+        EventPayload<Integer> baz = new EventPayloadInteger(12);
+        produceIntegerPayload.sendBody(baz);
+        produceFooQualifier.sendBody(456L);
+        produceBarQualifier.sendBody(495L);
+        produceObject.sendBody(777L);
+
+        assertThat(observer.getObjectEvents(), contains("string", foo, 1234, "test", bar, baz, 456L, 495L, 777L));
+        // assertThat(observer.getStringEvents(), contains("string", "test"));
+        assertThat(observer.getStringPayloadEvents(), contains(foo));
+        assertThat(observer.getIntegerPayloadEvents(), contains(bar, baz));
+        assertThat(observer.getDefaultQualifierEvents(), contains("string", foo, 1234, "test", bar, baz, 777L));
+        assertThat(observer.getFooQualifierEvents(), contains(456L));
+        assertThat(observer.getBarQualifierEvents(), contains(495L));
+    }
+
+    @ApplicationScoped
+    static class EventObserver {
+
+        private final List<Object> objectEvents = new ArrayList<>();
+
+        private final List<Object> defaultQualifierEvents = new ArrayList<>();
+
+        private final List<String> stringEvents = new ArrayList<>();
+
+        private final List<EventPayloadString> stringPayloadEvents = new ArrayList<>();
+
+        private final List<EventPayloadInteger> integerPayloadEvents = new ArrayList<>();
+
+        private final List<Long> fooQualifierEvents = new ArrayList<>();
+
+        private final List<Long> barQualifierEvents = new ArrayList<>();
+
+        void collectObjectEvents(@Observes Object event) {
+            objectEvents.add(event);
+        }
+
+        void collectStringEvents(@Observes String event) {
+            stringEvents.add(event);
+        }
+
+        void collectStringPayloadEvents(@Observes EventPayloadString event) {
+            stringPayloadEvents.add(event);
+        }
+
+        void collectIntegerPayloadEvents(@Observes EventPayloadInteger event) {
+            integerPayloadEvents.add(event);
+        }
+
+        void collectDefaultQualifierEvents(@Observes @Default Object event) {
+            defaultQualifierEvents.add(event);
+        }
+
+        void collectFooQualifierEvents(@Observes @FooQualifier Long event) {
+            fooQualifierEvents.add(event);
+        }
+
+        void collectBarQualifierEvents(@Observes @BarQualifier Long event) {
+            barQualifierEvents.add(event);
+        }
+
+        List<Object> getObjectEvents() {
+            return objectEvents;
+        }
+
+        List<String> getStringEvents() {
+            return stringEvents;
+        }
+
+        List<EventPayloadString> getStringPayloadEvents() {
+            return stringPayloadEvents;
+        }
+
+        List<EventPayloadInteger> getIntegerPayloadEvents() {
+            return integerPayloadEvents;
+        }
+
+        List<Object> getDefaultQualifierEvents() {
+            return defaultQualifierEvents;
+        }
+
+        List<Long> getFooQualifierEvents() {
+            return fooQualifierEvents;
+        }
+
+        List<Long> getBarQualifierEvents() {
+            return barQualifierEvents;
+        }
+
+        void reset() {
+            objectEvents.clear();
+            stringEvents.clear();
+            stringPayloadEvents.clear();
+            integerPayloadEvents.clear();
+            defaultQualifierEvents.clear();
+            fooQualifierEvents.clear();
+            barQualifierEvents.clear();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/InjectedEndpointTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/InjectedEndpointTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/InjectedEndpointTest.java
new file mode 100644
index 0000000..45ee927
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/InjectedEndpointTest.java
@@ -0,0 +1,68 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cdi.test;
+
+import java.util.concurrent.TimeUnit;
+import javax.inject.Inject;
+
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.bean.InjectedEndpointRoute;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+
+@RunWith(Arquillian.class)
+public class InjectedEndpointTest {
+
+    @Inject
+    @Uri("direct:inbound")
+    private ProducerTemplate inbound;
+
+    @Inject
+    private MockEndpoint outbound;
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test class
+            .addClass(InjectedEndpointRoute.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    public void sendMessageToInbound() throws InterruptedException {
+        outbound.expectedMessageCount(1);
+        outbound.expectedBodiesReceived("test");
+        
+        inbound.sendBody("test");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, outbound);
+    }
+}


[2/9] camel git commit: CAMEL-9201: Improved Camel CDI component

Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/PropertyEndpointTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/PropertyEndpointTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/PropertyEndpointTest.java
new file mode 100644
index 0000000..8cb284c
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/PropertyEndpointTest.java
@@ -0,0 +1,88 @@
+/**
+ * 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.cdi.test;
+
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.bean.CustomPropertiesCamelContext;
+import org.apache.camel.cdi.bean.PropertyEndpointRoute;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.properties.PropertiesComponent;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+
+@RunWith(Arquillian.class)
+public class PropertyEndpointTest {
+
+    @Inject
+    @Uri("direct:{{from}}")
+    private ProducerTemplate inbound;
+
+    @Inject
+    @Uri("mock:outbound")
+    private MockEndpoint outbound;
+
+    @Produces
+    @ApplicationScoped
+    @Named("properties")
+    private static PropertiesComponent configuration() {
+        Properties properties = new Properties();
+        properties.put("from", "inbound");
+        properties.put("to", "mock:outbound");
+        PropertiesComponent component = new PropertiesComponent();
+        component.setInitialProperties(properties);
+        return component;
+    }
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test classes
+            .addClasses(CustomPropertiesCamelContext.class, PropertyEndpointRoute.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    public void sendMessageToInbound() throws InterruptedException {
+        outbound.expectedMessageCount(1);
+        outbound.expectedBodiesReceived("test");
+        outbound.expectedHeaderReceived("header", "message from file");
+
+        inbound.sendBody("test");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, outbound);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/PropertyInjectTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/PropertyInjectTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/PropertyInjectTest.java
new file mode 100644
index 0000000..ac77ea4
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/PropertyInjectTest.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.cdi.test;
+
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+import javax.inject.Named;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.bean.PropertyInjectBean;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.properties.PropertiesComponent;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.junit.InSequence;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Arquillian.class)
+public class PropertyInjectTest {
+
+    @Produces
+    @ApplicationScoped
+    @Named("properties")
+    private static PropertiesComponent configuration() {
+        Properties properties = new Properties();
+        properties.put("property", "value");
+        PropertiesComponent component = new PropertiesComponent();
+        component.setInitialProperties(properties);
+        return component;
+    }
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test class
+            .addClass(PropertyInjectBean.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    @InSequence(1)
+    public void configureCamelContext(CamelContext context) throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:in").bean(PropertyInjectBean.class).to("mock:out");
+            }
+        });
+    }
+
+    @Test
+    @InSequence(2)
+    public void sendMessageToInbound(@Uri("direct:in") ProducerTemplate in, @Uri("mock:out") MockEndpoint out) throws InterruptedException {
+        out.expectedMessageCount(1);
+        out.expectedBodiesReceived("test");
+        out.expectedHeaderReceived("header", "value");
+        
+        in.sendBody("test");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, out);
+    }
+
+    @Test
+    @InSequence(3)
+    public void retrieveContextualReference(PropertyInjectBean bean) {
+        assertThat(bean.getProperty(), is(equalTo("value")));
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/QualifiedCamelContextTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/QualifiedCamelContextTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/QualifiedCamelContextTest.java
new file mode 100644
index 0000000..14b6e85
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/QualifiedCamelContextTest.java
@@ -0,0 +1,100 @@
+/**
+ * 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.cdi.test;
+
+import java.util.concurrent.TimeUnit;
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.qualifier.BarQualifier;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+
+@RunWith(Arquillian.class)
+public class QualifiedCamelContextTest {
+
+    @Inject
+    @BarQualifier
+    @Uri("direct:start")
+    private ProducerTemplate inbound;
+
+    @Inject
+    @BarQualifier
+    @Uri("mock:result")
+    private MockEndpoint outbound;
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test class
+            .addClass(QualifiedCamelContext.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    public void sendMessageToInbound() throws InterruptedException {
+        outbound.expectedMessageCount(1);
+        outbound.expectedBodiesReceived("test");
+
+        inbound.sendBody("test");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, outbound);
+    }
+
+    @BarQualifier
+    public static class CamelRoute extends RouteBuilder {
+
+        @Inject
+        @BarQualifier
+        @Uri("direct:start")
+        private Endpoint directEP;
+
+        @Inject
+        @BarQualifier
+        @Uri("mock:result")
+        private MockEndpoint mockEP;
+
+        @Override
+        public void configure() {
+            from(directEP).to(mockEP);
+        }
+    }
+}
+
+@BarQualifier
+@ApplicationScoped
+class QualifiedCamelContext extends DefaultCamelContext {
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/QualifiedMultiCamelContextTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/QualifiedMultiCamelContextTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/QualifiedMultiCamelContextTest.java
new file mode 100644
index 0000000..6ae1dca
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/QualifiedMultiCamelContextTest.java
@@ -0,0 +1,173 @@
+/**
+ * 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.cdi.test;
+
+import java.util.concurrent.TimeUnit;
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.ContextName;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.bean.DefaultCamelContextBean;
+import org.apache.camel.cdi.bean.FirstCamelContextRoute;
+import org.apache.camel.cdi.bean.UriEndpointRoute;
+import org.apache.camel.cdi.qualifier.BarQualifier;
+import org.apache.camel.cdi.qualifier.FooQualifier;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.junit.InSequence;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.apache.camel.cdi.expression.ExchangeExpression.fromCamelContext;
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Arquillian.class)
+public class QualifiedMultiCamelContextTest {
+
+    @Inject
+    private CamelContext defaultCamelContext;
+
+    @Inject @Uri("direct:inbound")
+    private ProducerTemplate defaultInbound;
+
+    @Inject @Uri("mock:outbound")
+    private MockEndpoint defaultOutbound;
+
+    @Inject @FooQualifier
+    private CamelContext firstCamelContext;
+
+    @Inject @FooQualifier @Uri("direct:inbound")
+    private ProducerTemplate firstInbound;
+
+    @Inject @FooQualifier @Uri("mock:outbound")
+    private MockEndpoint firstOutbound;
+
+    @Inject @BarQualifier
+    private CamelContext secondCamelContext;
+
+    @Inject @BarQualifier @Uri("direct:inbound")
+    private ProducerTemplate secondInbound;
+
+    @Inject @BarQualifier @Uri("mock:outbound")
+    private MockEndpoint secondOutbound;
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test classes
+            .addClasses(
+                DefaultCamelContextBean.class,
+                UriEndpointRoute.class,
+                FooCamelContext.class,
+                FirstCamelContextRoute.class,
+                BarCamelContext.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    @InSequence(1)
+    public void verifyCamelContexts() {
+        assertThat(defaultCamelContext.getName(), is(equalTo("camel-cdi")));
+        assertThat(firstCamelContext.getName(), is(equalTo("first")));
+        assertThat(secondCamelContext.getName(), is(equalTo("second")));
+
+        assertThat(defaultOutbound.getCamelContext().getName(), is(equalTo(defaultCamelContext.getName())));
+        assertThat(firstOutbound.getCamelContext().getName(), is(equalTo(firstCamelContext.getName())));
+        assertThat(secondOutbound.getCamelContext().getName(), is(equalTo(secondCamelContext.getName())));
+    }
+
+    @Test
+    @InSequence(2)
+    public void configureCamelContexts() throws Exception {
+        secondCamelContext.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:inbound").setHeader("context").constant("second").to("mock:outbound");
+            }
+        });
+    }
+
+    @Test
+    @InSequence(3)
+    public void sendMessageToDefaultCamelContextInbound() throws InterruptedException {
+        defaultOutbound.expectedMessageCount(1);
+        defaultOutbound.expectedBodiesReceived("test-default");
+        defaultOutbound.message(0).exchange().matches(fromCamelContext("camel-cdi"));
+
+        defaultInbound.sendBody("test-default");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, defaultOutbound);
+    }
+
+    @Test
+    @InSequence(4)
+    public void sendMessageToFirstCamelContextInbound() throws InterruptedException {
+        firstOutbound.expectedMessageCount(1);
+        firstOutbound.expectedBodiesReceived("test-first");
+        firstOutbound.expectedHeaderReceived("context", "first");
+        firstOutbound.message(0).exchange().matches(fromCamelContext("first"));
+
+        firstInbound.sendBody("test-first");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, firstOutbound);
+    }
+
+    @Test
+    @InSequence(5)
+    public void sendMessageToSecondCamelContextInbound() throws InterruptedException {
+        secondOutbound.expectedMessageCount(1);
+        secondOutbound.expectedBodiesReceived("test-second");
+        secondOutbound.expectedHeaderReceived("context", "second");
+        secondOutbound.message(0).exchange().matches(fromCamelContext("second"));
+
+        secondInbound.sendBody("test-second");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, secondOutbound);
+    }
+}
+
+@FooQualifier
+@ContextName("first")
+@ApplicationScoped
+class FooCamelContext extends DefaultCamelContext {
+
+}
+
+@BarQualifier
+@Named("second")
+@ApplicationScoped
+class BarCamelContext extends DefaultCamelContext {
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/RawEventEndpointTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/RawEventEndpointTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/RawEventEndpointTest.java
new file mode 100644
index 0000000..65aa4d0
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/RawEventEndpointTest.java
@@ -0,0 +1,110 @@
+/**
+ * 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.cdi.test;
+
+import java.util.concurrent.TimeUnit;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.event.Event;
+import javax.enterprise.event.Observes;
+import javax.inject.Inject;
+
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.CdiEventEndpoint;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+
+@RunWith(Arquillian.class)
+public class RawEventEndpointTest {
+
+    @Inject
+    private MockEndpoint consumed;
+
+    @Inject
+    private MockEndpoint produced;
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test classes
+            .addClasses(RawEventRoute.class, RawEventObserver.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Before
+    public void resetMock() {
+        consumed.reset();
+    }
+
+    @Test
+    public void sendEventToConsumer(Event<Object> event) throws InterruptedException {
+        consumed.expectedMessageCount(1);
+        consumed.expectedBodiesReceived("test");
+
+        event.select(String.class).fire("test");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, consumed);
+    }
+
+    @Test
+    public void sendMessageToProducer(@Uri("direct:produce") ProducerTemplate producer) throws InterruptedException {
+        long random =  Math.round(Math.random() * Long.MAX_VALUE);
+        produced.expectedMessageCount(1);
+        produced.expectedBodiesReceived(random);
+        consumed.expectedMessageCount(1);
+        consumed.expectedBodiesReceived(random);
+
+        producer.sendBody(random);
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, consumed, produced);
+    }
+}
+
+class RawEventRoute extends RouteBuilder {
+
+    @Inject
+    private CdiEventEndpoint rawEventEndpoint;
+
+    @Override
+    public void configure() {
+        from(rawEventEndpoint).to("mock:consumed");
+        from("direct:produce").to(rawEventEndpoint);
+    }
+}
+
+@ApplicationScoped
+class RawEventObserver {
+
+    void collectEvents(@Observes long event, @Uri("mock:produced") ProducerTemplate producer) {
+        producer.sendBody(event);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/RecipientListMethodTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/RecipientListMethodTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/RecipientListMethodTest.java
new file mode 100644
index 0000000..a37e656
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/RecipientListMethodTest.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.apache.camel.cdi.test;
+
+import java.util.concurrent.TimeUnit;
+import javax.inject.Inject;
+
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.bean.RecipientListMethodBean;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+
+@RunWith(Arquillian.class)
+public class RecipientListMethodTest {
+
+    @Inject
+    @Uri("direct:inbound")
+    private ProducerTemplate inbound;
+
+    @Inject
+    @Uri("mock:outbound1")
+    private MockEndpoint outbound1;
+
+    @Inject
+    @Uri("mock:outbound2")
+    private MockEndpoint outbound2;
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test class
+            .addClass(RecipientListMethodBean.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    public void consumeAnnotation() throws InterruptedException {
+        outbound1.expectedMessageCount(1);
+        outbound1.expectedBodiesReceived("test");
+
+        outbound2.expectedMessageCount(1);
+        outbound2.expectedBodiesReceived("test");
+
+        inbound.sendBody("test");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, outbound1);
+        assertIsSatisfied(2L, TimeUnit.SECONDS, outbound2);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/RouteDefinitionsFromXmlTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/RouteDefinitionsFromXmlTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/RouteDefinitionsFromXmlTest.java
new file mode 100644
index 0000000..70e291c
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/RouteDefinitionsFromXmlTest.java
@@ -0,0 +1,78 @@
+/**
+ * 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.cdi.test;
+
+import java.io.InputStream;
+import java.util.concurrent.TimeUnit;
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.model.ModelHelper;
+import org.apache.camel.model.RoutesDefinition;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+
+@RunWith(Arquillian.class)
+public class RouteDefinitionsFromXmlTest {
+
+    @Inject
+    @Uri("direct:inbound")
+    private ProducerTemplate inbound;
+
+    @Inject
+    @Uri("mock:outbound")
+    private MockEndpoint outbound;
+
+    @Produces
+    private RoutesDefinition routes(CamelContext context) throws Exception {
+        try (InputStream routes = getClass().getResourceAsStream("/routes.xml")) {
+            return ModelHelper.createModelFromXml(context, routes, RoutesDefinition.class);
+        }
+    }
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    public void sendMessageToInbound() throws InterruptedException {
+        outbound.expectedMessageCount(1);
+        outbound.expectedBodiesReceived("test");
+
+        inbound.sendBody("test");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, outbound);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UndefinedPropertyTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UndefinedPropertyTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UndefinedPropertyTest.java
new file mode 100644
index 0000000..8b88667
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UndefinedPropertyTest.java
@@ -0,0 +1,83 @@
+/**
+ * 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.cdi.test;
+
+import java.util.Properties;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+import javax.inject.Named;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.component.properties.PropertiesComponent;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+
+@RunWith(Arquillian.class)
+public class UndefinedPropertyTest {
+
+    @Produces
+    @ApplicationScoped
+    @Named("properties")
+    private static PropertiesComponent configuration() {
+        Properties properties = new Properties();
+        properties.put("from", "inbound");
+        // Do not add the looked up property for test purpose
+        //properties.put("to", "mock:outbound");
+        PropertiesComponent component = new PropertiesComponent();
+        component.setInitialProperties(properties);
+        return component;
+    }
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    public void lookupDefinedProperty(CamelContext context) throws Exception {
+        assertThat("Resolved property value is incorrect", context.resolvePropertyPlaceholders("{{from}}"), is(equalTo("inbound")));
+    }
+
+    @Test
+    public void lookupUndefinedProperty(CamelContext context) {
+        try {
+            context.resolvePropertyPlaceholders("{{to}}");
+            fail("No exception is thrown!");
+        } catch (Exception cause) {
+            assertThat("Exception thrown is incorrect", cause, is(instanceOf(IllegalArgumentException.class)));
+            assertThat("Exception message is incorrect", cause.getMessage(), is(equalTo("Property with key [to] not found in properties from text: {{to}}")));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UnsatisfiedContextForEndpointInjectTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UnsatisfiedContextForEndpointInjectTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UnsatisfiedContextForEndpointInjectTest.java
new file mode 100644
index 0000000..4e7da7a
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UnsatisfiedContextForEndpointInjectTest.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.apache.camel.cdi.test;
+
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.bean.EndpointInjectWrongContextRoute;
+import org.apache.camel.cdi.rule.ExpectedDeploymentException;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.rules.TestRule;
+import org.junit.runner.RunWith;
+
+import static org.hamcrest.Matchers.containsString;
+
+@RunWith(Arquillian.class)
+public class UnsatisfiedContextForEndpointInjectTest {
+
+    @ClassRule
+    public static TestRule exception = ExpectedDeploymentException.none()
+        .expect(RuntimeException.class)
+        .expectMessage(containsString("Error adding routes of type [" + EndpointInjectWrongContextRoute.class.getName() + "] to Camel context"))
+        .expectMessage(containsString("No Camel context with name [foo] is deployed!"));
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test class
+            .addClass(EndpointInjectWrongContextRoute.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    public void test() {
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UnstoppedCamelContextBeanTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UnstoppedCamelContextBeanTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UnstoppedCamelContextBeanTest.java
new file mode 100644
index 0000000..306d71c
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UnstoppedCamelContextBeanTest.java
@@ -0,0 +1,87 @@
+/**
+ * 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.cdi.test;
+
+import java.util.concurrent.TimeUnit;
+import javax.enterprise.context.ApplicationScoped;
+
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.bean.SimpleCamelRoute;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.rules.Verifier;
+import org.junit.runner.RunWith;
+
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Arquillian.class)
+public class UnstoppedCamelContextBeanTest {
+
+    @ClassRule
+    public static Verifier verifier = new Verifier() {
+        @Override
+        protected void verify() {
+            assertThat("Camel CDI hasn't stopped Camel context!", UnstoppedCamelContext.isStopCalled, is(equalTo(true)));
+        }
+    };
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test class
+            .addClasses(UnstoppedCamelContext.class, SimpleCamelRoute.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    public void sendMessageToInbound(@Uri("direct:start") ProducerTemplate inbound, @Uri("mock:result") MockEndpoint outbound) throws InterruptedException {
+        outbound.expectedMessageCount(1);
+        outbound.expectedBodiesReceived("test");
+
+        inbound.sendBody("test");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, outbound);
+    }
+}
+
+@ApplicationScoped
+class UnstoppedCamelContext extends DefaultCamelContext {
+
+    static boolean isStopCalled;
+
+    @Override
+    public void stop() throws Exception {
+        super.stop();
+        isStopCalled = true;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UnstoppedCamelContextProducerFieldTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UnstoppedCamelContextProducerFieldTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UnstoppedCamelContextProducerFieldTest.java
new file mode 100644
index 0000000..42da48b
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UnstoppedCamelContextProducerFieldTest.java
@@ -0,0 +1,82 @@
+/**
+ * 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.cdi.test;
+
+import java.util.concurrent.TimeUnit;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.ServiceStatus;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.bean.SimpleCamelRoute;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.rules.Verifier;
+import org.junit.runner.RunWith;
+
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Arquillian.class)
+public class UnstoppedCamelContextProducerFieldTest {
+
+    @ClassRule
+    public static Verifier verifier = new Verifier() {
+        @Override
+        protected void verify() {
+            assertThat("Camel CDI hasn't stopped Camel context!", context.getStatus(), is(equalTo(ServiceStatus.Stopped)));
+        }
+    };
+
+    @Produces
+    @ApplicationScoped
+    private static CamelContext context = new DefaultCamelContext();
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test class
+            .addClass(SimpleCamelRoute.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    public void sendMessageToInbound(@Uri("direct:start") ProducerTemplate inbound, @Uri("mock:result") MockEndpoint outbound) throws InterruptedException {
+        outbound.expectedMessageCount(1);
+        outbound.expectedBodiesReceived("test");
+
+        inbound.sendBody("test");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, outbound);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UnstoppedCamelContextProducerMethodTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UnstoppedCamelContextProducerMethodTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UnstoppedCamelContextProducerMethodTest.java
new file mode 100644
index 0000000..59db1cd
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UnstoppedCamelContextProducerMethodTest.java
@@ -0,0 +1,88 @@
+/**
+ * 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.cdi.test;
+
+import java.util.concurrent.TimeUnit;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.ServiceStatus;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.bean.SimpleCamelRoute;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.rules.Verifier;
+import org.junit.runner.RunWith;
+
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Arquillian.class)
+public class UnstoppedCamelContextProducerMethodTest {
+
+    @ClassRule
+    public static Verifier verifier = new Verifier() {
+        @Override
+        protected void verify() {
+            assertThat("Camel CDI hasn't stopped Camel context!", context.getStatus(), is(equalTo(ServiceStatus.Stopped)));
+        }
+    };
+
+    private static DefaultCamelContext context = new DefaultCamelContext();
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test class
+            .addClass(SimpleCamelRoute.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    public void sendMessageToInbound(@Uri("direct:start") ProducerTemplate inbound,
+                                     @Uri("mock:result") MockEndpoint outbound) throws InterruptedException {
+        outbound.expectedMessageCount(1);
+        outbound.expectedBodiesReceived("test");
+
+        inbound.sendBody("test");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, outbound);
+    }
+
+    @Produces
+    @ApplicationScoped
+    private CamelContext produceAndStartContext() {
+        context.setName("unstopped-context");
+        return context;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UriEndpointTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UriEndpointTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UriEndpointTest.java
new file mode 100644
index 0000000..2f47ef2
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UriEndpointTest.java
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cdi.test;
+
+import java.util.concurrent.TimeUnit;
+import javax.inject.Inject;
+
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.bean.UriEndpointRoute;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+
+@RunWith(Arquillian.class)
+public class UriEndpointTest {
+
+    @Inject
+    @Uri("direct:inbound")
+    private ProducerTemplate inbound;
+
+    @Inject
+    @Uri("mock:outbound")
+    private MockEndpoint outbound;
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test class
+            .addClass(UriEndpointRoute.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    public void sendMessageToInbound() throws InterruptedException {
+        outbound.expectedMessageCount(1);
+        outbound.expectedBodiesReceived("test");
+
+        inbound.sendBody("test");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, outbound);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UriQualifierWithContextTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UriQualifierWithContextTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UriQualifierWithContextTest.java
new file mode 100644
index 0000000..5e17b1d
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UriQualifierWithContextTest.java
@@ -0,0 +1,90 @@
+/**
+ * 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.cdi.test;
+
+import java.util.concurrent.TimeUnit;
+import javax.inject.Inject;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.ContextName;
+import org.apache.camel.cdi.Mock;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.bean.FirstCamelContextBean;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
+
+@RunWith(Arquillian.class)
+public class UriQualifierWithContextTest {
+
+    @Inject
+    @Uri(value = "mock:outbound", context = "first")
+    private MockEndpoint outbound;
+
+    @Inject
+    @Uri(value = "direct:inbound", context = "first")
+    private ProducerTemplate inbound;
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test classes
+            .addClasses(FirstCamelContextBean.class, UriWithContextRoute.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    public void sendMessageToInbound() throws InterruptedException {
+        outbound.expectedMessageCount(1);
+        outbound.expectedBodiesReceived("test");
+
+        inbound.sendBody("test");
+
+        assertIsSatisfied(2L, TimeUnit.SECONDS, outbound);
+    }
+}
+
+@ContextName("first")
+class UriWithContextRoute extends RouteBuilder {
+
+    @Inject
+    @Uri(value = "direct:inbound", context = "first")
+    Endpoint inbound;
+
+    @Inject
+    @Mock(value = "mock:outbound", context = "first")
+    MockEndpoint outbound;
+
+    @Override
+    public void configure() {
+        from(inbound).to(outbound);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UriWithWrongContextTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UriWithWrongContextTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UriWithWrongContextTest.java
new file mode 100644
index 0000000..e6297ab
--- /dev/null
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UriWithWrongContextTest.java
@@ -0,0 +1,78 @@
+/**
+ * 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.cdi.test;
+
+import javax.inject.Inject;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.cdi.CdiCamelExtension;
+import org.apache.camel.cdi.ContextName;
+import org.apache.camel.cdi.Uri;
+import org.apache.camel.cdi.bean.FirstCamelContextBean;
+import org.apache.camel.cdi.rule.ExpectedDeploymentException;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.rules.TestRule;
+import org.junit.runner.RunWith;
+
+import static org.hamcrest.Matchers.containsString;
+
+@RunWith(Arquillian.class)
+public class UriWithWrongContextTest {
+
+    @ClassRule
+    public static TestRule exception = ExpectedDeploymentException.none()
+        .expect(RuntimeException.class)
+        .expectMessage(containsString("Error adding routes of type [" + UriWithWrongContextRoute.class.getName() + "] to Camel context [first]"))
+        .expectMessage(containsString("Error injecting endpoint annotated with @org.apache.camel.cdi.Uri"))
+        .expectMessage(containsString("No Camel context with name [second] is deployed!"));
+
+    @Deployment
+    public static Archive<?> deployment() {
+        return ShrinkWrap.create(JavaArchive.class)
+            // Camel CDI
+            .addPackage(CdiCamelExtension.class.getPackage())
+            // Test classes
+            .addClasses(FirstCamelContextBean.class, UriWithWrongContextRoute.class)
+            // Bean archive deployment descriptor
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    public void test() {
+    }
+}
+
+@ContextName("first")
+class UriWithWrongContextRoute extends RouteBuilder {
+
+    @Inject
+    @Uri(value = "direct:inbound", context = "second")
+    Endpoint inbound;
+
+    @Override
+    public void configure() {
+        from(inbound).to("mock:outbound");
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/resources/META-INF/beans.xml b/components/camel-cdi/src/test/resources/META-INF/beans.xml
deleted file mode 100644
index 112d56d..0000000
--- a/components/camel-cdi/src/test/resources/META-INF/beans.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  Licensed to the Apache Software Foundation (ASF) under one or more
-  contributor license agreements.  See the NOTICE file distributed with
-  this work for additional information regarding copyright ownership.
-  The ASF licenses this file to You under the Apache License, Version 2.0
-  (the "License"); you may not use this file except in compliance with
-  the License.  You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
--->
-<beans/>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/resources/META-INF/camel.properties
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/resources/META-INF/camel.properties b/components/camel-cdi/src/test/resources/META-INF/camel.properties
deleted file mode 100644
index cb8d83f..0000000
--- a/components/camel-cdi/src/test/resources/META-INF/camel.properties
+++ /dev/null
@@ -1 +0,0 @@
-directEndpoint=direct:inject
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/resources/bar.properties
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/resources/bar.properties b/components/camel-cdi/src/test/resources/bar.properties
new file mode 100644
index 0000000..a55747a
--- /dev/null
+++ b/components/camel-cdi/src/test/resources/bar.properties
@@ -0,0 +1,18 @@
+## ------------------------------------------------------------------------
+## 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.
+## ------------------------------------------------------------------------
+
+bar.property=bar.value
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/resources/foo.properties
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/resources/foo.properties b/components/camel-cdi/src/test/resources/foo.properties
new file mode 100644
index 0000000..a969a68
--- /dev/null
+++ b/components/camel-cdi/src/test/resources/foo.properties
@@ -0,0 +1,18 @@
+## ------------------------------------------------------------------------
+## 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.
+## ------------------------------------------------------------------------
+
+foo.property=foo.value
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/resources/log4j.properties b/components/camel-cdi/src/test/resources/log4j.properties
index c026599..712a8a5 100644
--- a/components/camel-cdi/src/test/resources/log4j.properties
+++ b/components/camel-cdi/src/test/resources/log4j.properties
@@ -1,40 +1,37 @@
-## ---------------------------------------------------------------------------
+## ------------------------------------------------------------------------
 ## 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.
-## ---------------------------------------------------------------------------
+## ------------------------------------------------------------------------
 
 #
-# The logging properties used during tests..
+# The logging properties used for eclipse testing, We want to see debug output on the console.
 #
 log4j.rootLogger=INFO, file
 
-#log4j.logger.org.apache.camel.component.cdi=DEBUG
-#log4j.logger.org.apache.openwebbeans=DEBUG
+#log4j.logger.org.jboss.weld=DEBUG
+#log4j.logger.org.apache.webbeans=DEBUG
+#log4j.logger.org.apache.camel=DEBUG
+#log4j.logger.org.apache.camel.cdi=DEBUG
 
 # CONSOLE appender not used by default
 log4j.appender.out=org.apache.log4j.ConsoleAppender
 log4j.appender.out.layout=org.apache.log4j.PatternLayout
 log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
-# MDC
-#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %-10.10X{camel.breadcrumbId} - %-10.10X{camel.exchangeId} - %-10.10X{camel.correlationId} - %-10.10X{camel.routeId} - %m%n
 
 # File appender
 log4j.appender.file=org.apache.log4j.FileAppender
 log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d %-5p %c{1} - %m %n
 log4j.appender.file.file=target/camel-cdi-test.log
-log4j.appender.file.append=true
-log4j.appender.file.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
-# MDC
-#log4j.appender.file.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %-10.10X{camel.breadcrumbId} - %-10.10X{camel.exchangeId} - %-10.10X{camel.correlationId} - %-10.10X{camel.routeId} - %m%n

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/resources/logging.properties
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/resources/logging.properties b/components/camel-cdi/src/test/resources/logging.properties
new file mode 100644
index 0000000..6051671
--- /dev/null
+++ b/components/camel-cdi/src/test/resources/logging.properties
@@ -0,0 +1,50 @@
+#
+#
+#    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.
+#
+#
+############################################################
+#  	Default Logging Configuration File
+#
+# You can use a different file by specifying a filename
+# with the java.util.logging.config.file system property.
+# For example java -Djava.util.logging.config.file=myfile
+############################################################
+
+############################################################
+#  	Global properties
+############################################################
+
+# "handlers" specifies a comma separated list of log Handler
+# classes.  These handlers will be installed during VM startup.
+# Note that these classes must be on the system classpath.
+# By default we only configure a ConsoleHandler, which will only
+# show messages at the INFO and above levels.
+#handlers= java.util.logging.ConsoleHandler
+
+# To also add the FileHandler, use the following line instead.
+#handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler
+handlers=org.slf4j.bridge.SLF4JBridgeHandler
+
+# Default global logging level.
+# This specifies which kinds of events are logged across
+# all loggers.  For any given facility this global level
+# can be overriden by a facility specific level
+# Note that the ConsoleHandler also has a separate level
+# setting to limit messages printed to the console.
+.level=ALL
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/resources/placeholder.properties
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/resources/placeholder.properties b/components/camel-cdi/src/test/resources/placeholder.properties
new file mode 100644
index 0000000..8f3f0f5
--- /dev/null
+++ b/components/camel-cdi/src/test/resources/placeholder.properties
@@ -0,0 +1,18 @@
+## ------------------------------------------------------------------------
+## 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.
+## ------------------------------------------------------------------------
+
+header.message=message from file
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-cdi/src/test/resources/routes.xml
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/test/resources/routes.xml b/components/camel-cdi/src/test/resources/routes.xml
index 3506cff..29b3a21 100644
--- a/components/camel-cdi/src/test/resources/routes.xml
+++ b/components/camel-cdi/src/test/resources/routes.xml
@@ -1,8 +1,24 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<routes xmlns="http://camel.apache.org/schema/spring">
-  <route>
-    <from uri="direct:start"/>
-    <to uri="mock:results"/>
-  </route>
-</routes>
+<!--
+    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.
+-->
+
+<routes id="routes" xmlns="http://camel.apache.org/schema/spring">
+    <route id="xml-route">
+        <from uri="direct:inbound"/>
+        <to uri="mock:outbound"/>
+    </route>
+</routes>

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/components/camel-sjms/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-sjms/pom.xml b/components/camel-sjms/pom.xml
index f35f70b..db3fcd2 100644
--- a/components/camel-sjms/pom.xml
+++ b/components/camel-sjms/pom.xml
@@ -66,7 +66,7 @@
     <dependency>
       <groupId>org.apache.geronimo.specs</groupId>
       <artifactId>geronimo-annotation_1.0_spec</artifactId>
-      <version>${geronimo-annotation-spec-version}</version>
+      <version>${geronimo-annotation-1.0-spec-version}</version>
       <scope>provided</scope>
     </dependency>
 

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/examples/camel-example-cdi/pom.xml
----------------------------------------------------------------------
diff --git a/examples/camel-example-cdi/pom.xml b/examples/camel-example-cdi/pom.xml
index 4b05146..c555807 100644
--- a/examples/camel-example-cdi/pom.xml
+++ b/examples/camel-example-cdi/pom.xml
@@ -35,11 +35,11 @@
       <artifactId>camel-cdi</artifactId>
     </dependency>
 
-    <!-- cdi api -->
+    <!-- CDI API -->
     <dependency>
       <groupId>javax.enterprise</groupId>
       <artifactId>cdi-api</artifactId>
-      <version>1.2</version>
+      <version>${cdi-api-1.2-version}</version>
       <scope>provided</scope>
     </dependency>
 
@@ -56,19 +56,28 @@
       <version>${weld2-version}</version>
     </dependency>
     <dependency>
+      <groupId>org.apache.deltaspike.core</groupId>
+      <artifactId>deltaspike-core-api</artifactId>
+      <version>${deltaspike-version}</version>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
       <groupId>org.apache.deltaspike.cdictrl</groupId>
       <artifactId>deltaspike-cdictrl-weld</artifactId>
       <version>${deltaspike-version}</version>
+      <scope>runtime</scope>
     </dependency>
 
     <!-- use log4j as logger -->
     <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-log4j12</artifactId>
+      <scope>runtime</scope>
     </dependency>
     <dependency>
       <groupId>log4j</groupId>
       <artifactId>log4j</artifactId>
+      <scope>runtime</scope>
     </dependency>
 
   </dependencies>

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/examples/camel-example-cdi/src/main/java/org/apache/camel/example/cdi/MyRoutes.java
----------------------------------------------------------------------
diff --git a/examples/camel-example-cdi/src/main/java/org/apache/camel/example/cdi/MyRoutes.java b/examples/camel-example-cdi/src/main/java/org/apache/camel/example/cdi/MyRoutes.java
index c95de3c..246b5e8 100644
--- a/examples/camel-example-cdi/src/main/java/org/apache/camel/example/cdi/MyRoutes.java
+++ b/examples/camel-example-cdi/src/main/java/org/apache/camel/example/cdi/MyRoutes.java
@@ -20,13 +20,11 @@ import javax.inject.Inject;
 
 import org.apache.camel.Endpoint;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.cdi.ContextName;
 import org.apache.camel.cdi.Uri;
 
 /**
  * Configures all our Camel routes, components, endpoints and beans
  */
-@ContextName
 public class MyRoutes extends RouteBuilder {
 
     @Inject
@@ -38,7 +36,7 @@ public class MyRoutes extends RouteBuilder {
     private Endpoint resultEndpoint;
 
     @Override
-    public void configure() throws Exception {
+    public void configure() {
         // you can configure the route rule with Java DSL here
 
         from(inputEndpoint)

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index d8d0495..e9c7346 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -50,7 +50,7 @@
     <aries-blueprint-proxy-version>1.0.1</aries-blueprint-proxy-version>
     <aries-blueprint-proxy-impl-version>1.0.4</aries-blueprint-proxy-impl-version>
     <aries-util-version>1.1.0</aries-util-version>
-    <arquillian-junit-container-version>1.1.10.Final</arquillian-junit-container-version>
+    <arquillian-version>1.1.10.Final</arquillian-version>
     <arquillian-weld-se-embedded-version>1.0.0.CR9</arquillian-weld-se-embedded-version>
     <asm-bundle-version>3.3.1_1</asm-bundle-version>
     <asm-version>3.3.1</asm-version>
@@ -88,7 +88,9 @@
     <cassandra-unit-version>2.2.2.1</cassandra-unit-version>
     <castor-version>1.3.3</castor-version>
     <castor-bundle-version>1.3.3_1</castor-bundle-version>
-    <cdi-api-version>1.1</cdi-api-version>
+    <cdi-api-1.0-version>1.0-SP4</cdi-api-1.0-version>
+    <cdi-api-1.1-version>1.1</cdi-api-1.1-version>
+    <cdi-api-1.2-version>1.2</cdi-api-1.2-version>
     <cglib-bundle-version>3.2.0_1</cglib-bundle-version>
     <cglib-version>3.2.0</cglib-version>
     <chunk-templates-version>3.1.3</chunk-templates-version>
@@ -174,15 +176,18 @@
     <freemarker-version>2.3.23</freemarker-version>
     <gentlyweb-bundle-version>1.5_1</gentlyweb-bundle-version>
     <geocoder-java-version>0.16</geocoder-java-version>
-    <geronimo-annotation-spec-version>1.1.1</geronimo-annotation-spec-version>
+    <geronimo-annotation-1.0-spec-version>1.1.1</geronimo-annotation-1.0-spec-version>
+    <geronimo-annotation-1.2-spec-version>1.0</geronimo-annotation-1.2-spec-version>
     <geronimo-atinject-1.0-spec-version>1.0</geronimo-atinject-1.0-spec-version>
     <geronimo-ejb_3.1_spec-version>1.0.2</geronimo-ejb_3.1_spec-version>
     <geronimo-el-spec-version>1.0.1</geronimo-el-spec-version>
     <geronimo-interceptor-1.1-spec-version>1.0</geronimo-interceptor-1.1-spec-version>
+    <geronimo-interceptor-1.2-spec-version>1.0</geronimo-interceptor-1.2-spec-version>
     <geronimo-j2ee-connector-spec-version>2.0.0</geronimo-j2ee-connector-spec-version>
     <geronimo-j2ee-jacc-spec-version>1.1</geronimo-j2ee-jacc-spec-version>
     <geronimo-j2ee-management-spec-version>1.1</geronimo-j2ee-management-spec-version>
     <geronimo-jcdi-1.0-spec-version>1.0</geronimo-jcdi-1.0-spec-version>
+    <geronimo-jcdi-1.1-spec-version>1.0</geronimo-jcdi-1.1-spec-version>
     <geronimo-jms-spec-version>1.1.1</geronimo-jms-spec-version>
     <geronimo-jpa2-spec-version>1.1</geronimo-jpa2-spec-version>
     <geronimo-jsp-spec-version>1.1</geronimo-jsp-spec-version>
@@ -400,7 +405,8 @@
     <netty-version>4.0.33.Final</netty-version>
     <noggit-bundle-version>0.5_1</noggit-bundle-version>
     <!-- should be in-sync with deltaspike -->
-    <openwebbeans-version>1.2.0</openwebbeans-version>
+    <openwebbeans1-version>1.2.7</openwebbeans1-version>
+    <openwebbeans-version>1.6.2</openwebbeans-version>
     <oauth-provider-bundle-version>20100527_1</oauth-provider-bundle-version>
     <olingo2-version>2.0.5</olingo2-version>
     <olingo-odata2-core-bundle-version>2.0.5_1</olingo-odata2-core-bundle-version>
@@ -459,6 +465,7 @@
     <servlet-api-3.0-version>1.0</servlet-api-3.0-version>
     <servlet-version-range>[2.5,4)</servlet-version-range>
     <shiro-version>1.2.4</shiro-version>
+    <shrinkwrap-descriptors-version>2.0.0-alpha-8</shrinkwrap-descriptors-version>
     <sip-api-version>1.1</sip-api-version>
     <slf4j-api-version>1.7.13</slf4j-api-version>
     <slf4j-version>1.7.13</slf4j-version>
@@ -533,6 +540,7 @@
     <velocity-version>1.7</velocity-version>
     <vertx-version>3.2.0</vertx-version>
     <vysper-version>0.7</vysper-version>
+    <weld1-version>1.1.28.Final</weld1-version>
     <weld2-version>2.3.2.Final</weld2-version>
     <werken-xpath-bundle-version>0.9.4_5</werken-xpath-bundle-version>
     <woodstox-version>4.4.1</woodstox-version>

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/platforms/karaf/features/src/main/resources/features.xml
----------------------------------------------------------------------
diff --git a/platforms/karaf/features/src/main/resources/features.xml b/platforms/karaf/features/src/main/resources/features.xml
index 1ce577d..75ebde4 100644
--- a/platforms/karaf/features/src/main/resources/features.xml
+++ b/platforms/karaf/features/src/main/resources/features.xml
@@ -874,7 +874,9 @@
     <bundle>mvn:org.apache.camel/camel-josql/${project.version}</bundle>
   </feature>
   <feature name='camel-jpa' version='${project.version}' resolver='(obr)' start-level='50'>
-    <bundle dependency='true'>mvn:org.apache.geronimo.specs/geronimo-annotation_1.0_spec/${geronimo-annotation-spec-version}</bundle>
+    <bundle dependency='true'>
+      mvn:org.apache.geronimo.specs/geronimo-annotation_1.0_spec/${geronimo-annotation-1.0-spec-version}
+    </bundle>
     <bundle dependency='true'>mvn:org.apache.geronimo.specs/geronimo-jpa_2.0_spec/${geronimo-jpa2-spec-version}</bundle>
     <bundle dependency='true'>mvn:org.apache.geronimo.specs/geronimo-servlet_3.0_spec/${geronimo-servlet-spec-version}</bundle>
     <feature version='${spring-version-range-karaf}'>spring-tx</feature>

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/tests/camel-itest-cdi/pom.xml
----------------------------------------------------------------------
diff --git a/tests/camel-itest-cdi/pom.xml b/tests/camel-itest-cdi/pom.xml
index 2fda15c..fb954e9 100644
--- a/tests/camel-itest-cdi/pom.xml
+++ b/tests/camel-itest-cdi/pom.xml
@@ -34,11 +34,11 @@
       <artifactId>camel-cdi</artifactId>
     </dependency>
 
-    <!-- cdi api -->
+    <!-- CDI API -->
     <dependency>
       <groupId>javax.enterprise</groupId>
       <artifactId>cdi-api</artifactId>
-      <version>${cdi-api-version}</version>
+      <version>${cdi-api-1.1-version}</version>
     </dependency>
 
     <!-- logging -->
@@ -53,14 +53,6 @@
 
     <!-- for testing -->
     <dependency>
-      <groupId>org.apache.deltaspike.core</groupId>
-      <artifactId>deltaspike-core-impl</artifactId>
-      <version>${deltaspike-version}</version>
-      <scope>test</scope>
-    </dependency>
-
-    <!-- for testing -->
-    <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <scope>test</scope>
@@ -68,7 +60,7 @@
     <dependency>
       <groupId>org.jboss.arquillian.junit</groupId>
       <artifactId>arquillian-junit-container</artifactId>
-      <version>${arquillian-junit-container-version}</version>
+      <version>${arquillian-version}</version>
       <scope>test</scope>
     </dependency>
   </dependencies>
@@ -76,33 +68,21 @@
   <profiles>
 
     <profile>
-      <id>weld2</id>
+      <id>weld-1.2</id>
       <activation>
         <activeByDefault>true</activeByDefault>
       </activation>
       <dependencies>
         <dependency>
-          <groupId>org.apache.deltaspike.cdictrl</groupId>
-          <artifactId>deltaspike-cdictrl-weld</artifactId>
-          <version>${deltaspike-version}</version>
-          <scope>test</scope>
-        </dependency>
-        <dependency>
-          <groupId>org.jboss.weld.se</groupId>
-          <artifactId>weld-se-core</artifactId>
+          <groupId>org.jboss.weld</groupId>
+          <artifactId>weld-core-impl</artifactId>
           <version>${weld2-version}</version>
-          <scope>provided</scope>
+          <scope>test</scope>
         </dependency>
         <dependency>
           <groupId>org.jboss.arquillian.container</groupId>
           <artifactId>arquillian-weld-se-embedded-1.1</artifactId>
           <version>${arquillian-weld-se-embedded-version}</version>
-          <exclusions>
-            <exclusion>
-              <groupId>org.jboss.arquillian.container</groupId>
-              <artifactId>arquillian-container-spi</artifactId>
-            </exclusion>
-          </exclusions>
           <scope>test</scope>
         </dependency>
       </dependencies>

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/CamelContextA.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/CamelContextA.java b/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/CamelContextA.java
new file mode 100644
index 0000000..3ca839c
--- /dev/null
+++ b/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/CamelContextA.java
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.itest.cdi;
+
+import javax.enterprise.context.ApplicationScoped;
+
+import org.apache.camel.cdi.CdiCamelContext;
+import org.apache.camel.cdi.ContextName;
+
+@ApplicationScoped
+@ContextName("contextA")
+public class CamelContextA extends CdiCamelContext {
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0421c24d/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/CamelContextB.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/CamelContextB.java b/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/CamelContextB.java
new file mode 100644
index 0000000..2889cbd
--- /dev/null
+++ b/tests/camel-itest-cdi/src/main/java/org/apache/camel/itest/cdi/CamelContextB.java
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.itest.cdi;
+
+import javax.enterprise.context.ApplicationScoped;
+
+import org.apache.camel.cdi.CdiCamelContext;
+import org.apache.camel.cdi.ContextName;
+
+@ApplicationScoped
+@ContextName("contextB")
+public class CamelContextB extends CdiCamelContext {
+
+}